[9877] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3470 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 17 21:07:21 1998

Date: Mon, 17 Aug 98 18:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 17 Aug 1998     Volume: 8 Number: 3470

Today's topics:
        can "foreach ..." and "while ..." share loop control? <Robert.Lopez@abq.sc.philips.com>
    Re: Complex Regular Expression <ajohnson@gpu.srv.ualberta.ca>
    Re: Converting to lowecase (Kirill Sapelkin)
    Re: eq and == difference <peter@richmd.demon.co.uk>
        I don't know a mean of script. <iychung@kaebi.com>
    Re: localtime showing wrong info <nobody@nowhere.com>
    Re: MD5 and perl <briant@packeteer.com>
        Net::LDAPaspi - Doesn't Work! Why? <mkruse@rens.com>
    Re: newbie question (Abigail)
    Re: Output to the top of the file (Abigail)
        pattern matching with uc and lc julzrulz@my-dejanews.com
    Re: Pattern substitution using perl (Abigail)
        Perl install Dynaloader failures on Solaris <dsilver@ucsd.edu>
        Pg::perl <gflan@avalon.net>
        Problems with file opening <dan@fearsome.net>
        Programmer Needed/Contractual basis - 100 hours/Mo goodtimeweb@my-dejanews.com
    Re: Random Number <grant.griffin@nospam.com>
    Re: Random Number (Greg Bacon)
    Re: Random Number (Abigail)
    Re: Regex Mania - (was Re: X-file (?=...), case postpon (Patrick Timmins)
        Splitting numbers? <gflan@avalon.net>
    Re: Splitting numbers? (Greg Bacon)
    Re: Splitting numbers? (Craig Berry)
    Re: Splitting numbers? (Bob Trieger)
    Re: su on NT <pkeefe@ix.netcom.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 17 Aug 1998 17:38:45 -0600
From: Robert Lopez <Robert.Lopez@abq.sc.philips.com>
Subject: can "foreach ..." and "while ..." share loop control?
Message-Id: <jc6zpd3kwl6.fsf@abqn07.ato.sca.philips.com>


I wrote a program to read the source file for building a NIS email
alias table and writing out alias declarations for .mailrc files. 
The source of the file has alias information that is organized like:

team_b: john,glenda,  diane, roes
team_h: aaron,carol,	fred,  jane
team_m: bill, joy, frank, team_b, team_h

The data is written for inclusion into .mailrc is organized like:

alias team_b john, glenda, diane, roes
alias team_h aaron, carol, fred, jane
alias team_m bill, joy, frank, team_b, team_h

It worked fine for a while but now the source file has to have some
lists added to it that have hundreds of names and are organized like:

department_2315: evan.adams,bill.anthony,carol.armenta,frank.armstrong,
	anna.baker,carol.balder,frank.carter,duane.caston.linda.david,
	...
        cindy.williams,ted.vromans

I was reading the source file into an array and then processing with
  foreach $line (@my_array) {
    ... 
  }

My question is:
Inside of the foreach block is there a way to have a sub-block that
shares the function of grabbing the next line so it can grab the
entire list off of multiple lines?

Somethink like:

  foreach $line (@my_array) {
     ....
     while ($line =~ /,$/) {
	....
     }
  }


-- 
Robert.Lopez@abq.sc.philips.com



------------------------------

Date: Mon, 17 Aug 1998 18:42:13 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Complex Regular Expression
Message-Id: <35D8BFD5.3677E404@gpu.srv.ualberta.ca>

Kevin Holbrook wrote:
> 
> Sorry for my ignorance here, but does anyone know the proper expression
> for matching a comma in the middle of a double-quoted alpha-numeric
> string?
> 
> i.e. to find the comma in :
> 
> "Hello, Dolly"
> 
complex?

$_='"Hello, Dolly"';
print "Found it\n" if /,/;

perhaps you had something a little different
in mind when posing your question?

regards
andrew


------------------------------

Date: 17 Aug 1998 17:38:57 -0700
From: znanie@best.com (Kirill Sapelkin)
Subject: Re: Converting to lowecase
Message-Id: <znanie.903400545@shell5.ba.best.com>

Why not make a newsgroup for perl help or perl newbie.  There is such
a group for linux.

Old people die, new people are born.   The new ones don't know what the
old ones do (did).  That's life.

Kirill


>   There are "newbies" in several different areas (new to programming,
>   perl, CGI, or even newbies to Usenet itself).

>   Most often, it is 3-4 of those simultaneously that really get
>   the flame throwers on HI.

>   I don't think this newsgroup (it is not a "board" as in BBS, it is
>   a newsgroup, as in Usenet) is hostile to newbies who are having
>   problems with perl or even with programming in general.


>   It is hostile to people who:

>      ----------
>      Post a Question that has been Asked Frequently in the past.

>      (Many man-hours spent on collecting answers validated by
>       *hundreds* of sets of eyes, wasted.  Makes folks mad.
>      )



>      Post a question easily answered by 60-120 seconds of word
>      searching in the docs that *come with* perl.

>      (Many man-hours spent on carefully documenting how perl is
>       to behave, also validated by *hundreds* of sets of eyes, wasted.  
>       Makes folks mad.
>      )



>      ----------
>      Post a question that is not about perl or Perl.

>      (This is most often a misplaced CGI question. Even a newbie
>       can follow the links given in the Perl FAQ, part 9 to
>       help decide which newsgroup is most likely to yeild
>       answer paydirt...

>       Annoyance at off-topic postings is common in most newsgroups.

>       Nothing perl-specific about that one, see the FAQs posted
>       in the   news.announce.newusers   newsgroup.
>      )


>      ----------
>      Demand an answer, or mark as Urgent.

>      (Volunteers are unconcerned with your anxiousness. 

>       Consultants/contractors are much more responsive to
>       such concerns.

>       Also not a perl-specific annoyance on Usenet.
>      )


>      ----------
>      Ask for an answer by email because they don't read the newsgroup.

>      (Like sneaking into a Wedding reception and hoping nobody knows
>       that you don't know bride nor groom.

>       Even that would be OK, but most here want to help as many
>       people as possible. Emailed answers benefit only one person.
>       Posted answers are open for all to see. (and the clever
>       newbie (and experienced hacker, for that matter) can get
>       their answer in seconds from on of the Usenet archives,
>       eg. www.dejanews.com

>       Once again, common to all of Usenet, not just this newsgroup.
>      ).


>If you read this newsgroup, then you know that it has a whole bunch
>of traffic (If not, then don't say so ;-).  

>It seems to me that more than half of all posts are
>time-wasters, as listed above.

>(That's 50-100 "time wasters" each and every day. 

> Some folks have been reading the newsgroup for years!

> Every thousand or so of those triggers a venting. 

> Unfortunate if your post happens to be the thousandth one  ;-)
>)

>How do you think the folks who answer a lot of questions find your
>question to answer? They read lots of articles!

>Hence, they waste a lot of time (there are also Frequently Used Keywords
>that many use to automatically discard the Silly Questions, it pays
>to put a _little_ bit of thought into composing your Subject: header)



>: If someone ask a
>: question that is in the experts eye pretty basic, instead of offering a tip
>: or solution the poor newbie is slagged of and told to read the manuals (like
>: if he had not tried this allready).

>Exactly.

>If a keyword search would find it in under two minutes, then we
>deduce that the did *not* try the docs first.

>Given the large number of "keyword search" answerable questions posted
>here every day, I think many haven't "tried this allready" (sic).


>:     I remember the friendly enviroment there used to be on similar Amiga
>: programing boards some years ago. There people would help eachother out no
>: matter what kind of stupid questions was asked. 


>BBSes and Usenet newsgroups are not the same thing.

>Or did you mean on an Amiga newsgroup?



>Also consider that the experienced ones here are the *nice* ones.

>Who else would put up with seeing the same 2 dozen questions tens or
>hundreds of times, *and keep on reading the newsgroup* ?

>The easily bored ones have already wasted enough time on 
>Silly Questions, and no longer even read the newsgroup.

>( Given the high correlation between eccentricities, such as being
>  easily disgusted with rote repetition, and high intelligence,
>  the most valuable of all Perl experts have likely already been 
>  driven away from the newsgroup. (no slight to the "hardy" ones
>  reading this post ;-)

>  Let's do our small part to not drive away the few remaining ones.
>)



>: If this board are supposed to
>: be for proffesional programmers only, then it should be clearly stated
>: somewhere.

>It is not for professional programmers only.

>But, given the 'comp.lang' in the name, folks are expected to have
>some small degree of technical savvy.  

>Like being able to read  ;-)

>And at least finding out the rules of a foreign society (that's right,
>Usenet has its own little set of "rules", mentioned in the above
>newsgroup) lest they execute a faux pas while attempting to solicit
>a favor (answer).



>: And I'm apologizing to the tousands of people i have bothered with my
>: question.


>Now there is a normal, well-socialized response to finding out that
>you made a social blunder. You have character.

>Much better than the usual newbie response of "screw the rules,
>gimme my answer"...



>You are hereby declared "reformed"  ;-)

>Use the docs and be a perl "insider"!


>--
>    Tad McClellan                          SGML Consulting
>    tadmc@metronet.com                     Perl programming
>    Fort Worth, Texas


------------------------------

Date: Tue, 18 Aug 1998 00:17:34 +0100
From: Peter Richmond <peter@richmd.demon.co.uk>
Subject: Re: eq and == difference
Message-Id: <35D8BA0E.C4FD22D2@richmd.demon.co.uk>

Craig Berry wrote:
> 
> Andre L. (alecler@cam.org) wrote:
> : > Essentially, == works for scalars such as numbers. eq works for
> : > strings. You can check out the docs at http://www.perl.org/ for a more
> : > complete run down of the perl comparison operators.
> :
> : Strings are also scalars, may I point out.
> 
> Exactly.  A fine example of yet another reason why consulting the doc is
> superior to asking on clpm.

sorry.

-- 
Peter Richmond.
--
Home : Sunderland, United Kingdom
Web  : www.richmd.demon.co.uk
Pager: 01426 281 367


------------------------------

Date: Tue, 18 Aug 1998 08:33:43 +0900
From: "Cabin Drop" <iychung@kaebi.com>
Subject: I don't know a mean of script.
Message-Id: <6rael0$8an$1@news.kornet.nm.kr>

HI everyone.

Explain the following scriptor;

-----------------------
 require LWP::UserAgent;        (g
require HTTP::Request;          (h
 require "$s[$i[0]].pm";  >

 #  srand (time() ^ ($$ + ($$ << 15)));    (i
 #  while($c<$n) {
 #   &random;
 #   $c++;
 #  }


 #print "<";       (j
 #print "<";
 #print "<";
 #print "<";
 #print "<>\n";


 package XXX;

 $ua->agent("Mozilla/4.04 (X11; I; NetBSD 1.3 i386; Nav)");     (k

 1;       (l
----------------

I can't run this CGI on perl. I don't understand Numbered Line.
Please help me.

Thank you.









------------------------------

Date: Tue, 18 Aug 1998 09:42:33 +1000
From: Allan Chandler <nobody@nowhere.com>
Subject: Re: localtime showing wrong info
Message-Id: <35D8BFE8.DDE5EBD3@nowhere.com>

Steve . wrote:

> Why does localtime show everything correctly except for the month.  My
> system clock is set to August, but it is showing 7 for the month
> number.  The year shows 98 and the day shows 14.  Is the month
> starting with 0?  If so, what's the deal with that?  If not, what's
> going wrong?  This is on Solaris.  Thanks.
>
> STeve

  Your definition of 'correctly' is broken.  It does what the doco says,
hence it is correct.  The range of months is 0-11 as it is with the
standard C library, I beleive.  This is probably because a month would
tend to be turned into text (Jan, Feb, etc) with an array lookup and C
arrays are based a zero.

There doesn't seem to be any requirement to index into an array for year
or day of month since they don't have special names (year of the
rat/snake/etc notwithstanding).

You'll notice that the day of the week is 0-6 as it would also be likely
to used as an index to generate Sun, Mon and so forth.

Regards,
AC.



------------------------------

Date: Mon, 17 Aug 1998 16:08:32 -0700
From: Brian Tiemann <briant@packeteer.com>
Subject: Re: MD5 and perl
Message-Id: <35D8B7F0.D136046E@packeteer.com>

Brian Tiemann wrote:

>         Has anyone done an MD5 module in perl? And I don't mean MD5.pm; that's
> just a perl interface to compiled C code. I mean an actual
> implementation of the MD5 hashing routine in pure perl.

	Sorry, sorry... pay no attention. I just went through the DejaNews
archives and found the code I need. I always end up doing that... :)

	Just for the record, though... the most common doubt echoed on the
newsgroup just a few days ago regarding a perl MD5 implementation was
speed. To those who were pointing out perl's lack of efficiency here,
remember that for a lot of MD5-related operations, all we're needing to
hash is a small string, like a password or a cookie. No need to grunge
through megabytes of a file's content. :) So it does have a place, just
as long as the input is small.

	I guess that's how I got away with it in Visual Basic...

Brian


------------------------------

Date: Mon, 17 Aug 1998 19:41:51 -0500
From: Matt Kruse <mkruse@rens.com>
Subject: Net::LDAPaspi - Doesn't Work! Why?
Message-Id: <35D8CDCF.45C9@rens.com>

I'm trying to use Net::LDAPapi to connect to an LDAP Server.
Perl = Latest ActiveState build, based on 5.005, and LDAPapi says
it only needs 5.004.

But when I try to just do "use Net::LDAPapi;" I get the following
message box pop up on my NT Server:

     +--------------------------------------------+
     | The dynamic link library Perl.dll could not|
     | be found in the specified path...          |
     +--------------------------------------------+

Then Perl returns:

Can't load 'C:\Perl\site\5.005\lib/auto/Net/LDAPapi/LDAPapi.dll' for
module Net:
:LDAPapi: load_file:The specified module could not be found at
C:\Perl\5.005\lib
/MSWin32-x86-object/DynaLoader.pm line 168.

Any clue what could be wrong?

I desperately need this to work. :) Thanks!

--
Matt Kruse
mkruse@rens.com
Renaissance Worldwide


------------------------------

Date: 17 Aug 1998 22:59:56 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: newbie question
Message-Id: <6raclc$p7f$5@client3.news.psi.net>

SDunkin@oxfordinc.com (SDunkin@oxfordinc.com) wrote on MDCCCXII September
MCMXCIII in <URL: news:6r9o1v$m5$1@nnrp1.dejanews.com>:
++ Greetings, I'm trying to break a comma separated file into columns. Because I
++ am just starting to learn perl, I am encountering some difficulty. Can
++ someone point me in the right direction on how to do this?

"man perl"



Abigail
-- 
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'


------------------------------

Date: 17 Aug 1998 23:02:37 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Output to the top of the file
Message-Id: <6racqd$p7f$6@client3.news.psi.net>

jm@kolumbus.fi (jm@kolumbus.fi) wrote on MDCCCXII September MCMXCIII in
<URL: news:35D8377C.F0E2BD6B@kolumbus.fi>:
++ Hi!
++ I have a script that reads form and adds the data to a file. It works
++ fine, but I'd like to put the data always to the top of the file.

RTFFAQ.


Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


------------------------------

Date: Tue, 18 Aug 1998 00:31:12 GMT
From: julzrulz@my-dejanews.com
Subject: pattern matching with uc and lc
Message-Id: <6rai0g$55s$1@nnrp1.dejanews.com>

What I am trying to do is take a line,
split on spaces, put items into an array,
compare each array item with the items
in the list.  If the item is not found
Capitalize the first letter, and lowercase
the rest.  If the item is found keep it.
Problem is when you do the split you get
CFP,  It looks at the word plus the comma,
   ^
so it doesn't find the word and makes it lower case
Cfp,

Here's what the list.pl looks like:
CFP
USC
CFS

Here's what $rep_name looks like
DAVID J. SMITH, CFP, CFS
I want it to look like this:
David J. Smith, CFP, CFS

if (!open(LIST, "../list.pl")){
    print "can't open file";
   }
my %list;
chomp, $list{$_} = 1 while <LIST>;
close LIST;

$rep_name;
@rep = split (/ /, $rep_name);

foreach (@rep) {
   next if $list{$_};    # if word matches word in list, keep value
   $_ = ucfirst lc ($_); # capitalize first letter only and replace
}
$rep_name = join ' ', @rep;

Thanks,
julzrulz@my-dejanews.com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: 17 Aug 1998 23:03:52 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Pattern substitution using perl
Message-Id: <6racso$p7f$7@client3.news.psi.net>

zaxaz@my-dejanews.com (zaxaz@my-dejanews.com) wrote on MDCCCXII September
MCMXCIII in <URL: news:6r9ojv$1mb$1@nnrp1.dejanews.com>:
++ I am trying to substitute leading and trailing double quotes from each line i
++ a numbe of files. Is this something easily accomplished using perl. I would
++ like to substitute the pattern then rewrite each file in sequence.


Yes, it is easy.


Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


------------------------------

Date: Mon, 17 Aug 1998 16:36:51 -0700
From: Doug K Silver <dsilver@ucsd.edu>
Subject: Perl install Dynaloader failures on Solaris
Message-Id: <35D8BE92.6039@ucsd.edu>

I'm trying to get Apache Active Server Pages w/mod_perl to work when I
ran into this:

[Mon Aug 17 09:45:27 1998] [error] Can't load
'/pub/gnu/lib/perl5/sun4-solaris/5.00404/auto/SDBM_File/SDBM_File.so'
for module SDBM_File: ld.so.1: /pub/apache/sbin/httpsd: fatal:
relocation error: symbol not found: Perl_stack_sp: referenced in
/pub/gnu/lib/perl5/sun4-solaris/5.00404/auto/SDBM_File/SDBM_File.so at
/pub/gnu/lib/perl5/sun4-solaris/5.00404/DynaLoader.pm line 166.

 at /pub/gnu/lib/perl5/site_perl/Apache/ASP.pm line 26
BEGIN failed--compilation aborted at
/pub/gnu/lib/perl5/site_perl/Apache/ASP.pm line 26.

[Mon Aug 17 09:45:27 1998] [error] Undefined subroutine
&Apache::ASP::handler called.

so I tried to recompile perl to see if it would give me the same
error and it does:
Can't load '../lib/auto/Fcntl/Fcntl.so' for module Fcntl: ld.so.1:
 ./perl: fatal: relocation error: symbol not found: main: referenced in
 ../lib/auto/Fcntl/Fcntl.so at ../lib/DynaLoader.pm line 166

same for lib/{filehand, io_dup, io_pipe, io_sock, io_taint, io_tell,
io_udp, io_xs, ndbm, odbm, opcode, open2, open3, posix, safe1, safe2,
sdbm, socket}

I'm sure I ignored these test errors initially (oops), but now I can't!
:(

Any suggestions for how to solve this?

Thanks in advance.
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Doug Silver
ECE Computer Support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
  Platform:
    osname=solaris, osvers=2.5, archname=sun4-solaris
    uname='sunos denali 5.5 generic_103093-17 sun4c sparc sunw,sun_4_60
'
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=n useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc', optimize='-O', gccversion=2.7.2.2
    cppflags='-I/pub/include'
    ccflags ='-I/pub/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =''
    libpth=/pub/lib /pub/gnu/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fpic', lddlflags='-G'


------------------------------

Date: Mon, 17 Aug 1998 19:02:21 -0500
From: Greg Flanders <gflan@avalon.net>
Subject: Pg::perl
Message-Id: <Pine.LNX.3.96.980817190033.4633A-100000@darwin.xdsl.avalon.net>

Has anyone used Pg::perl's error control facilities? I'm doing some queries
using $result = $conn-> exec($query), but sometimes the query fails, and I want
to be able to check that before I try and access $result. The man page is a
little cryptic, I should be able to check with

$result_status = $result->resultStatus;

right? how exactly do I use this?

thanks!

greg

Please cc any replies to gflan@avalon.net



------------------------------

Date: Tue, 18 Aug 1998 01:56:37 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: Problems with file opening
Message-Id: <903401833.9079.0.nnrp-06.c2deb1c5@news.demon.co.uk>

OK, I'm driving myself crazy trying to figure this out, so I hope somebody
will be able to help:

In my (Perl) CGI script I use $foo to describe a directory path - call it
'a/b/c'

After a great deal of other stuff (which all works fine) I ask the script to
simply create a file 'a/b/c/bar.htm' and then close it without writing any
data to the file. Simple, right? So I thought. I am using:

open(FILE, ">/$foo/bar.htm") || die "I can't create that file\n";
close(FILE);

and the script returns the dreaded "Internal Script Error" when I try
running it.

When I remove those two lines using

# open(FILE, ">/$foo/bar.htm") || die "I can't create that file\n";
# close(FILE);

the script runs fine and everything else goes as planned - it is definitely
these two lines that are causing the problems. SO, I have narrowed the
problem down to one of two things:

(i) Incorrect syntax - but the syntax is the same as I have used in my other
scripts, and also seems to (roughly) match that advised in Perl Programming
(the bible)

(ii) Incorrect file/directory permissions? But the file can't have any
permissions until it is created, right? And I have had no trouble writing
other files to this directory!

This i really starting to grind me down and I've tried everything I can
think of to work around it, so please help!

Dan Adams
dan@fearsome.net







------------------------------

Date: Tue, 18 Aug 1998 00:35:53 GMT
From: goodtimeweb@my-dejanews.com
Subject: Programmer Needed/Contractual basis - 100 hours/Mo
Message-Id: <6rai99$5k1$1@nnrp1.dejanews.com>

Contact goodtime@goodtimeweb for details.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: Mon, 17 Aug 1998 17:13:47 -0500
From: Grant Griffin <grant.griffin@nospam.com>
To: Greg Bacon <gbacon@cs.uah.edu>
Subject: Re: Random Number
Message-Id: <35D8AB1B.68328817@nospam.com>

Greg Bacon wrote:

> In article <35D86952.C43DE25C@nospam.com>,
>         Grant Griffin <grant.griffin@nospam.com> writes:
> : I know that "Windows People" (if that's what Darren is) supposedly deser
> : automatic scorn around here, but to my knowledge, Windows comes with not
> : "grep".
>
> Well, for one thing, you're putting words in my mouth.  Please stop.
> For another, Win{95,98,NT} do have text file search built-in.
>

Sorry--that one came across from me wrong.

> Never thought of the concept of searching for patterns in text files?
> Please be serious.  Even simple and simple-minded editors have some
> sort of search functionality.
>

Please be respectful. ;-)

True--but editors search only one file at a time.  It is a small leap of concept
to search multiple files, but a beginner might never make this small leap.
(Small leaps can be big.  For example, the mechanical technology to make a
phonograph was around for several hundred years before Thomas Edision thought of
the idea.)

> I use this (and I believe there will be a newer version in the upcoming
> Perl Cookbook by tchrist and gnat):
>

Thanks, I'll try yours out some time.

By the way, since I seem to have elected myself The Newbies Advocate, I would
like to remind the more seasoned among you that the "regular expression search"
that came as the default mode of my Turbo Pascal grep is _very_ confusing to
newbies.  Grep can be used very nicely for most purposes _without_ regular
expressions, and this was a major pothole for me until I learned about regular
expressions via Perl.  (The literal term "regular expression" is so nebulous as
to be meaningless.)  Therefore, as a default mode, regular expression matching
should be turned off in any program to be recommended to newbies.

=g2




------------------------------

Date: 17 Aug 1998 23:44:34 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Random Number
Message-Id: <6raf92$39o$13@info.uah.edu>

In article <35D8AB1B.68328817@nospam.com>,
	Grant Griffin <grant.griffin@nospam.com> writes:
: Greg Bacon wrote:
: > Never thought of the concept of searching for patterns in text files?
: > Please be serious.  Even simple and simple-minded editors have some
: > sort of search functionality.
: 
: True--but editors search only one file at a time.  It is a small leap of
: to search multiple files, but a beginner might never make this small lea
: (Small leaps can be big.  For example, the mechanical technology to make
: phonograph was around for several hundred years before Thomas Edision th
: the idea.)

The full-fledged technology is around now!  Even dainbread DOS has find
(but not the One True find) that will search text files.  I remember
using the Norton Utilities text file search on DOS and Win3.1 machines.
Your point is irrelevant.

: > I use this (and I believe there will be a newer version in the upcoming
: > Perl Cookbook by tchrist and gnat):
: 
: Thanks, I'll try yours out some time.

You should.  It rocks.

: By the way, since I seem to have elected myself The Newbies Advocate,

Start by setting a good example.  Please limit the lengths of your lines
to around 72 characters or so.

: I 
: like to remind the more seasoned among you that the "regular expression 
: that came as the default mode of my Turbo Pascal grep is _very_ confusing to
: newbies.

I disagree.  The principle of YANETUT applies.  I didn't have any idea
whatsoever of what regular expressions are (an instructor in high school
said grep searched for regular expressions and you could devote an
entire course to teaching regular expressions--although he didn't even
spend a day :-), but I still used the searching facilities of grep and
vi and less with no problem at all.

As the self-appointed Veteran Advocate, I'd like to remind the greener
among you that seeing the same questions again and again and rudely
being asked to read the FAQs and docs to people is highly, highly
annoying.  I'll renew my (and Aggie's) offer to answer FAQs with the
sweetest and most charming pointer to the docs for $1/instance.  Put
your money where your mouth is.

: Grep can be used very nicely for most purposes _without_ regular
: expressions, and this was a major pothole for me until I learned about r
: expressions via Perl.

Why?

: (The literal term "regular expression" is so nebulous as
: to be meaningless.)

In MRE, jfriedl gives a humorous account of the transliteration to
Japanese of `regular expression' has something to do with the genitalia
(I believe--I don't have my copy in front of me).

Not only is it nebulous, but it's a lie (backrefs)!

: Therefore, as a default mode, regular expression matching
: should be turned off in any program to be recommended to newbies.

Regular expression searching doesn't get in the way unless you happen
to put a metacharacter in the search pattern.  Most people who don't
realize they've done this will scratch their heads and supply a less
restrictive pattern.  No harm done.

Greg
-- 
Why do people give each other flowers? To celebrate various important
occasions, they're killing living creatures? Why restrict it to plants?
"Sweetheart, let's make up.  Have this deceased squirrel."
    -- Jerry Seinfeld


------------------------------

Date: 18 Aug 1998 00:23:08 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Random Number
Message-Id: <6rahhc$qqg$1@client3.news.psi.net>

Grant Griffin (grant.griffin@nospam.com) wrote on MDCCCXII September
MCMXCIII in <URL: news:35D8A250.72018491@nospam.com>:
++ 
++ Another idea is to add a big link to the Perl FAQ and/or a search engine
++ (we _have_ the technology!) to some of the primary Perl web sites.
++ Honestly, the FAQ does not jump off the screen at you, starting from
++ http://www.perl.org/.  (I _still_ don't know how to find it from there.)

And should it? There are no signs to my house on the freeway either.
If you have perl, you already *HAVE* the faq. No need to browse the
web and find it.

++ Also, nearly everybody must visit the "Acquiring Software" page at least

Why? I've never seen that page. I don't think it's necessary.

++ once: why not link to it there.  Likewise, when I look at the "Perl
++ Support" page, http://www.perl.org/support.html, it doesn't say, "You
++ should grep your documents first, then see the Perl FAQ, then master Perl,
++ then call us", it says, "Many of our members also answer questions in the
++ Usenet newsgroup comp.lang.perl.misc."

Just because some people from perl.org happen to answer questions here
doesn't mean people here want to see FAQs. And even if the people form
perl.org love to answer FAQs (I doubt they do), the rest of us don't.

As for reading FAQs first, that has nothing to do with Perl, or with
comp.lang.perl.misc. That's something you have to do for each group.

++ I am convinced that if The Big Guns of Perl _truly_ wanted to reduce the
++ "dumb question" problem, they could make a bigger dent in the problem with
++ much less effort simply by making the Perl web pages more slanted towards
++ "Read the facts first, idiot".  (To TomC: My apologies, if any of of these
++ simple ideas get adopted, thus ruining some of your fun.)

I doubt the idiots will even bother to read a web page.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


------------------------------

Date: Mon, 17 Aug 1998 14:57:45 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Regex Mania - (was Re: X-file (?=...), case postponed.)
Message-Id: <6r9gd9$l96$1@nnrp1.dejanews.com>

In article <6r2ecn$76$1@nnrp1.dejanews.com>,
  ptimmins@netserv.unmc.edu (Patrick Timmins) wrote:
> Regarding @arr = split /(?=(.*))/s, "Just another Perl Hacker\n";
>
> Ronald, Abigail, ... Friends ... Romans, countrymen! Lend me your
> ears! I come to praise regexes, not to bury them!
>
[snip out alot of true things that have nothing to do with the special
case of spilt found in @arr = split /(?=(.*))/s, "Just another Perl
Hacker\n";]

So I *did* score alot points. I was shooting at the wrong basket. Does
this mean they won't be figured into my "points per game" or shooting
percentage?

Patrick Timmins
--
Who, in an Elijah idiom, is not as dense as he may appear to be. Note that
I did *not* say less dense than he may appear to be.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: Mon, 17 Aug 1998 18:52:20 -0500
From: Greg Flanders <gflan@avalon.net>
Subject: Splitting numbers?
Message-Id: <Pine.LNX.3.96.980817184817.4610A-100000@darwin.xdsl.avalon.net>

Say I've got a decimal number, and I want to split it into two variables, can I
use split()? As in 

$time = 4.55;
@splitted = split(/./, $number);
$minuteTime = @splitted[0];
$secondTime = @splitted[1];

what am I doing wrong here? Will split not do numbers?

thanks!

greg

Please cc any responses to gflan@avalon.net




------------------------------

Date: 18 Aug 1998 00:23:52 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Splitting numbers?
Message-Id: <6rahio$39o$14@info.uah.edu>

[Posted and mailed]

In article <Pine.LNX.3.96.980817184817.4610A-100000@darwin.xdsl.avalon.net>,
	Greg Flanders <gflan@avalon.net> writes:
: Say I've got a decimal number, and I want to split it into two
: variables, can I use split()? As in 
: 
: $time = 4.55;
: @splitted = split(/./, $number);
: $minuteTime = @splitted[0];
: $secondTime = @splitted[1];
: 
: what am I doing wrong here? Will split not do numbers?

It will, but . (dot) is a metacharacter in regular expressions that
matches any character (there is an exception).  You can backwhack
a metacharacter like

    @nums = split /\./, $number;

which takes away its special meaning.

Read the perlre manpage for the full story on Perl's extremely
useful and powerful regular expressions.

Greg
-- 
Definition of a Jury: Twelve persons chosen to decide who has the better
lawyer. 
    -- Robert Frost 


------------------------------

Date: 18 Aug 1998 00:25:10 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Splitting numbers?
Message-Id: <6rahl6$sgm$2@marina.cinenet.net>

Greg Flanders (gflan@avalon.net) wrote:
: Say I've got a decimal number, and I want to split it into two variables, can I
: use split()? As in 
: 
: $time = 4.55;
: @splitted = split(/./, $number);
                     ^
'.' has a special meaning in a regex.  See perlre for the details.  To
make it mean just plain old period/decimal-point/that-dot-char, you need
to escape it:  /\./

: $minuteTime = @splitted[0];
: $secondTime = @splitted[1];

Note that you're not doing what you think you are, there.  You're doing
array slices that work by coincidence.  A dereferenced array element,
being a scalar, should start with $, not @. 

: what am I doing wrong here? Will split not do numbers?

When fed to a regex, Perl automagically treats numbers as their string
representations.  The gory details of this are...well, gory...but that's a
good enough rule of thumb for the present. 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


------------------------------

Date: Tue, 18 Aug 1998 00:28:42 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Splitting numbers?
Message-Id: <6rai1i$daj$1@strato.ultra.net>

[ posted and mailed ]

Greg Flanders <gflan@avalon.net> wrote:
-> Say I've got a decimal number, and I want to split it into two variables, can
->  I
-> use split()? As in 
-> 
-> $time = 4.55;
-> @splitted = split(/./, $number);
-> $minuteTime = @splitted[0];
-> $secondTime = @splitted[1];
-> 
-> what am I doing wrong here? Will split not do numbers?

You aren't using strict or -w to start.

You are initializing $time and then trying to split $number. When is number 
initialized?

You aren't escaping the period which is a meta character in your split 
statement.

You are calling elements of an array using a @ instead of a $.  -w would have 
pointed that out.

Try this:

#!/usr/bin/perl -w
use strict;
my $time = '4.55';
my ($minutes,$seconds) = split/\./,$time;


HTH

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-400-1972 
  Ext: 1949 and let the jerk that answers know 
  that his toll free number was sent as spam. "


------------------------------

Date: Mon, 17 Aug 1998 19:50:33 -0400
From: "Pete Keefe" <pkeefe@ix.netcom.com>
Subject: Re: su on NT
Message-Id: <6rafjm$r53@sjx-ixn3.ix.netcom.com>

In the NT 4.0 server resource kit there is a SU.EXE program  that looks like
it will do what you are want.
Good luck
Pete

James O Flynn wrote in message <35D83B78.A54E8CE3@hursley.ibm.com>...
>New to using perl on NT and I need to be able to start
>jobs with particular uids and gids.
>How do I:
>unless ( fork )
>  {
>    $UID = "user";
>    $GID = "group";
>    exec( "script" );
>  }
>???
>With the deamon running as a service set up by administrator?
>Cheers,
>James.
>--
>4920616d206e6f742061206e756d62657221




------------------------------

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 3470
**************************************

home help back first fref pref prev next nref lref last post