[8099] in Perl-Users-Digest
Perl-Users Digest, Issue: 1718 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 24 00:07:10 1998
Date: Fri, 23 Jan 98 21:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 23 Jan 1998 Volume: 8 Number: 1718
Today's topics:
Re: @ == @, comparing arrays <tchrist@mox.perl.com>
Re: `dir`command in IIS3.0 gives no output <toby@salina.net>
Re: `dir`command in IIS3.0 gives no output <corky@ultranet.com>
Re: are there something like "Perl for Idiot" in Bookst (J. Bacon)
Re: Browser Identification? <*@qz.to>
clearing hash of hashes in sub (reuse) (David Efflandt)
Re: clearing hash of hashes in sub (reuse) <zenin@best.com>
Re: diff that operates on Perl variables? <joseph@5sigma.com>
Re: email address <ke4krt@mindspring.com>
Re: email address (Clay Irving)
Re: email address <*@qz.to>
Re: Hashes w/ case-insensitive keys <tchrist@mox.perl.com>
Help Renaming Files.... <marcin@polaccess.com>
Re: Help w/ regexp <*@qz.to>
Re: Help! How do I call a C function from Perl? <joseph@5sigma.com>
Help! <sh@rdwa.com>
HELP--Perl on MacIntosh <gloria@akula.com>
Re: HELP--Perl on MacIntosh (Adam Schneider)
Help: file locking for writing into a file using flock( <tkho@technologist.com>
Is Perl cron-able <jgaff@_no_spam_technologist.com>
Is Perl cron-able? <jgaff@_no_spam_technologist.com>
Re: Is Perl cron-able? (David Efflandt)
Re: Logical 'and' in regex? (Tad McClellan)
Re: multithread perl (David Efflandt)
Re: nested +?* in regexp (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Re: Please please help a beginner... (Smith and O'Halloran)
Re: Reading persistent logs <joseph@5sigma.com>
Server Push Problem <mhanson@arrowweb.com>
Re: Subroutine prototype puzzlement <joegottman@nospam.worldnet.att.net>
Survival Of perl <nazira@cadvision.com>
Re: Survival Of perl <tchrist@mox.perl.com>
Re: UNIX to %$$@! Win: Script Won't Go <jefpin@bergen.org>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Jan 1998 03:41:45 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: @ == @, comparing arrays
Message-Id: <6abntp$3lc$1@csnews.cs.colorado.edu>
Keywords: hornwort magma pandemic wristband
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, mjd@op.net (Mark-Jason Dominus) writes:
The more you now about a data set, the better you can tailor
your algorithm. While for arbitrary arrays, the mentioned
solution is of course insufficient, yet for many, it is fine.
For example, arrays of numbers or login names.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"You can only measure the size of your head from the inside." --Larry Wall
------------------------------
Date: Fri, 23 Jan 1998 20:34:46 -0600
From: Toby Gebhart <toby@salina.net>
Subject: Re: `dir`command in IIS3.0 gives no output
Message-Id: <34C95346.2BE9E045@salina.net>
Try $ls = `command /c dir\/b $directory_name`;
I think that should work, I don't think Perl finds the dir command because
it is a function of the shell, rather than a separate executable.
Toby Gebhart
mailto:toby@salina.net
Kerry Peterson wrote:
> We're trying to implement a search script in perl using IIS3.0 . It is
> an adaptation of Matt Wright's Simple-Search script. It should be able
> to read through the wwwroot directory tree, and output the names of all
> files containing the searched-for string of characters.
>
> When the script is called from a web page, the dir command should be
> able to read in the contents of the directory for processing, as in:
>
> $ls = `dir\/b $directory_name`; #which should put the output of dir
> command in $ls
>
> However, the $ls variable contains nothing.
>
> This method seems to work fine from the command line, but when run via
> the internet, it reads nothing.
>
> For the sake of testing, I've given full permissions to the files and
> directories via NTFS and IIS, but it still won't work. What else might
> we try?
>
> Thank you,
>
> Kerry Peterson
> Graduate College
> University of Northern Iowa
------------------------------
Date: Fri, 23 Jan 1998 23:16:54 -0500
From: Bob Trieger <corky@ultranet.com>
Subject: Re: `dir`command in IIS3.0 gives no output
Message-Id: <34C96B35.14B8@ultranet.com>
Toby Gebhart wrote:
>
> Try $ls = `command /c dir\/b $directory_name`;
> I think that should work, I don't think Perl finds the dir command because
> it is a function of the shell, rather than a separate executable.
That won't work either, tried it 2 weeks ago when I was looking for a
solution to the same problem. It is somewhere between IIS and perl32
that the problem is occuring, the script works from the command line.
------------------------------
Date: 24 Jan 1998 04:02:43 GMT
From: jwbacon@ix.netcom.com (J. Bacon)
Subject: Re: are there something like "Perl for Idiot" in Bookstore?
Message-Id: <6abp53$l2g@sjx-ixn7.ix.netcom.com>
I am hoping to see an O'Reilly book soon covering all the permutations I just
read on "I need a man to lick me into a frenzy". That series was one of the
better nutshell progressions I have seen -- books or not.
I --HATE-- to recommend anything titled "Teach yourself /.*/ in 21 days", but
the one for Perl/Windows NT got me asking myself the 'right' questions, which
made subsequent purchases easier.
***** What is a "free" gift? Aren't all gifts free? *****
Jim Bacon
jwbacon@ix.netcom.com
303-666-9455 (H) 303-581-9635 ext. 329 (W)
------------------------------
Date: 24 Jan 1998 04:51:46 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Browser Identification?
Message-Id: <qz$9801232340@qz.little-neck.ny.us>
darkcyde <bazaillion@primary.net> wrote:
> I am writing a Perl script to do browser identification,
That's nice.
> does anyone know of a web site that has all the latest UserAgent variables
> for all the latest browsers.
Someone might, but I'd reckon that person is probably reading a newsgroup
about browsers, not perl.
> I need them for Netscape Navigator 3.0, Netscape Communicator 4.0,
> Internet Explorer 3.0, and Internet Explorer 4.0.
I use a copy of lynx that I've tweaked to my tastes, it identifies
itself as "Lynx/2.6FM(eli) libwww-FM/2.14". HTH.
Elijah
------
found that the lynx-dev folk had fixed some nice features between 2.4 and 2.6
------------------------------
Date: Sat, 24 Jan 1998 02:04:02 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: clearing hash of hashes in sub (reuse)
Message-Id: <34c93aec.442094@flood.xnet.com>
I am using a hash of hashes like $foo{$bar}{$var} in a sub and sorting
on the value of a particular $var and I just want to make sure the
whole thing is empty when I reuse it.
Just wondering if the following statement would clear the entire hash
of hashes or whether it references something entirely different:
undef %foo;
If I use 'local %foo;' or 'my %foo;' at the sub beginning would the
hash of hashes disappear when returning from the sub or is old data
still there next time the sub is used? When I tried those before I
still seemed to get old data along with the new.
Currently I 'undef @barlist;' going into the sub and 'push @barlist,
$bar;' in a loop to use as a key instead of %foo to make sure I am
using fresh data. That seems to work, but I wonder the hash of hashes
is growing in memory with old data.
David Efflandt/Elgin, IL USA
efflandt@xnet.com http://www.xnet.com/~efflandt/
------------------------------
Date: 24 Jan 1998 02:20:11 GMT
From: Zenin <zenin@best.com>
Subject: Re: clearing hash of hashes in sub (reuse)
Message-Id: <885608633.511399@thrush.omix.com>
David Efflandt <efflandt@xnet.com> wrote:
: I am using a hash of hashes like $foo{$bar}{$var} in a sub
>snip<
: Just wondering if the following statement would clear the entire hash
: undef %foo;
Yes.
: If I use 'local %foo;' or 'my %foo;' at the sub beginning would the
: hash of hashes disappear when returning from the sub
Yes.
: or is old data still there next time the sub is used?
No, not if the declaration is done within the sub block and not
externally.
: When I tried those before I still seemed to get old data along with the
: new.
You did place it inside the sub block, yes?
sub foo {
my %foo;
...stuff
}
: Currently I 'undef @barlist;' going into the sub and 'push @barlist,
: $bar;' in a loop to use as a key instead of %foo to make sure I am
: using fresh data.
Ack. Just use my %foo. If this doesn't work for you, post the
exact code you're trying to do.
: That seems to work, but I wonder the hash of hashes
: is growing in memory with old data.
Perl should do GC when the variable goes out of scope. Please post
code if it's not doing this.
--
-Zenin
zenin@best.com
------------------------------
Date: Fri, 23 Jan 1998 18:32:27 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: diff that operates on Perl variables?
Message-Id: <34C943B2.D83D994E@5sigma.com>
I don't believe there is a module that does this at present.
How exactly should the differences be represented in the output?
???
-joseph
http://www.effectiveperl.com
Steve Goldstein wrote:
>
> Is there a Perl implementation of the unix diff utility that works on
> variables rather than files?
------------------------------
Date: Fri, 23 Jan 1998 21:12:35 -0500
From: Phil Heaton <ke4krt@mindspring.com>
Subject: Re: email address
Message-Id: <34C94E13.3E7D9601@mindspring.com>
G. E. Terry wrote:
>
> What would be the best way to test a variable called $emailaddress to see if
> it contains an email address in the correct format?
How about:
$emailaddress = "joe.blow\@here.com" ;
if($email eq $emailaddress) { do whatever }
else { do the other }
Phil
--
Phil Heaton
ke4krt@mindspring.com
http://www.qsl.net/ke4krt
------------------------------
Date: 23 Jan 1998 21:29:04 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: email address
Message-Id: <6abjlg$2r6@panix.com>
In <6ab03p$2gj$1@ns2.adult-host.net> admin@net-ops.net (G. E. Terry) writes:
>What would be the best way to test a variable called $emailaddress to see if
>it contains an email address in the correct format?
The subject of Email address validation has been discussed in great depth in
this newsgroup. Bottom line: You can't. You'll have one whopper of a time
trying to define "correct format."
--
Clay Irving <clay@panix.com> I think, therefore I am. I think?
http://www.panix.com/~clay/
------------------------------
Date: 24 Jan 1998 04:30:09 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: email address
Message-Id: <qz$9801232314@qz.little-neck.ny.us>
G. E. Terry <admin@net-ops.net> wrote:
> What would be the best way to test a variable called $emailaddress to see if
> it contains an email address in the correct format?
I'd use /^<?.+@.+>?$/ myself, mostly because I have read the RFC that
defines these things and think anything stricter is either wrong or a
waste of time.
Some people will make all sorts of claims about what a valid email
address is. They are welcome to send me mail at <*@qz.to> or <@qz.to>
(that's a <del> in the localpart, you may need quotes to get your
software to like it) with their answers for correction.
Elijah
------
you could be stricter on the domain part, but really, don't bother
------------------------------
Date: 24 Jan 1998 03:45:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Hashes w/ case-insensitive keys
Message-Id: <6abo45$3lc$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, jdf@pobox.com (Jonathan Feinberg) writes:
:> ah - a PoB situation. perhaps you want to hack that particular ...
: ^^^
:Please gloss for the slow-on-the-uptake (pronounced: "me").
"Prisoner of Bill" -- those held captive, unwillingly or otherwise,
by the contemptible Microsoft monopoly.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"111% of crap is everything." --Larry Wall
------------------------------
Date: Fri, 23 Jan 1998 22:24:39 -0600
From: Marcin Pasek <marcin@polaccess.com>
Subject: Help Renaming Files....
Message-Id: <34C96D07.2A14@polaccess.com>
I have a bunch of HTM files and I want to rename them so that they are
in some kind of order....someone wrote a short program that he said
will work but it's not...Well this program has to take each file name
put XDR and then consecutive number right after so that I get names
like
xdr1.htm, xdr2.htm, xdr3.htm and so far....Here is a code can someone
help figure this one out...Thanks
#!/usr/bin/perl
opendir(DIR,".");
$count = 1;
while ($thisfile=readdir(DIR))
{
$_ = $thisfile;
if (/\.htm/)
{
$newfile = "xdr" . $count . ".htm";
system ("mv $thisfile $newfile");
print "I moved $thisfile $newfile\n";
}
}
exit(0);
------------------------------
Date: 24 Jan 1998 04:14:42 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Help w/ regexp
Message-Id: <qz$9801232303@qz.little-neck.ny.us>
Douglas Clifton <doug1@weboneinc.com> wrote:
> To be more to-the-point: given an array that has N
> tab delimited fields ending in a number (day into the
> year) I want to remove all lines not in the above
> mentioned range. Rather than using a loop and split()
> I thought it might be simplier to use grep():
It's not, but map may be useful.
> @log = grep /[$beg-$end]\n$/, @log;
This is not goign to work. You missunderstand [] in regular expressions.
It creates a character class, which can span consecutive ascii values
with "-", not a range of numbers. You can use an RE to match a range of
numbers, but there is a fair amount of work. Freidl's _Mastering Regular
Expressions_ makes an extensive example out of matching valid days of a
month. See p115, as I recall.
Elijah
------
posted about this in another thread recently
------------------------------
Date: Fri, 23 Jan 1998 18:43:35 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Help! How do I call a C function from Perl?
Message-Id: <34C9464E.3ABA6D25@5sigma.com>
The example I have online as Item 47 at
http://www.effectiveperl.com/toc.html
might be easier to follow. Why don't you try it. If it doesn't
work, please report back to the newsgroup with the output from
perl -V (capital V) and some error messages.
-joseph
http://www.effectiveperl.com
cathy_chiang@hotmail.com wrote:
>
> I am having trouble figuring out how to call C functions from Perl. I
> have read through the perlstut man page. Following are my questions
> regarding the approach outlined in perlstut:
>
> 1) I was following example 1 in the man page. [...]
------------------------------
Date: Fri, 23 Jan 1998 23:48:17 -0500
From: "Sherrie" <sh@rdwa.com>
Subject: Help!
Message-Id: <6abr9m$ljf@bgtnsc03.worldnet.att.net>
I know nothing...yes, nothing about Perl. My company is signing up with a
stock market data service that will upload, every 15 minutes, a fixed with,
pipe-delimited text file with one company or quote information per line.
We have roughly 30 or so previously designed 'holdings' pages...a different
company on each page. My job is to figure out how to take a single quote
from the uploaded text file and display it within a particular area of each
page.
If anyone can help me...please...
Sherrie
sh@rdwa.com
------------------------------
Date: Fri, 23 Jan 1998 22:30:15 -0500
From: gloria <gloria@akula.com>
Subject: HELP--Perl on MacIntosh
Message-Id: <34C96045.9A5F9E00@akula.com>
Hi I'm new here and I am looking for any info about Perl for the
MacIntosh
environment. I am a software applications instructor and I was asked by
my company to set up a curriculum for CGI/Perl. Can anyone guide me as
to what I need on my system to study this? Is there a Perl interpreter I
need? If so where can I download it for a Mac running on system 7.5.5?
Do I
need to run a Web server? WebStar?
Any help will be gratefully appreciated. You can write me direct.Thank
you.
Gloria Rabinowitz
http://www.akula.com/~gloria
gloria@akula.com
------------------------------
Date: Fri, 23 Jan 1998 22:14:45 -0600
From: NO_SPAM_acs@bitstream.net (Adam Schneider)
Subject: Re: HELP--Perl on MacIntosh
Message-Id: <NO_SPAM_acs-2301982214450001@acs.bitstream.net>
gloria@akula.com wrote:
> Hi I'm new here and I am looking for any info about Perl for the MacIntosh
> environment. I am a software applications instructor and I was asked by
> my company to set up a curriculum for CGI/Perl. Can anyone guide me as
> to what I need on my system to study this? Is there a Perl interpreter I
> need? If so where can I download it for a Mac running on system 7.5.5?
It's called (surprise, surprise) MacPerl. Read the MacPerl Q & A document
at http://err.ethz.ch/~neeri/macintosh/perl-qa.html to find out more. You
may also want to join the MacPerl mailing list; instructions are in the Q
& A.
The latest MacPerl application is here:
ftp://sunsite.cnlab-switch.ch/software/platform/macos/perl/Mac_Perl_519r4_appl.bin
> Do I need to run a Web server? WebStar?
To play with CGIs, you need a server, but you don't need WebStar. You can
download an excellent freeware server called Quid Pro Quo from
http://www.socialeng.com/.
Adam
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Adam Schneider * Minneapolis, Minnesota, USA
E-mail: schneider "at" pobox.com
WWW: http://pobox.com/~schneider/adam.html
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: Fri, 23 Jan 1998 17:13:59 -0800
From: Tommy <tkho@technologist.com>
Subject: Help: file locking for writing into a file using flock() and seek().
Message-Id: <34C94057.A305E2CF@technologist.com>
Does anyone know how to lock a file while a script is writing a file.
What I need is to have a subroutine that:
1. check if the file is locked
2. lock a file from the next user when the file is not locked
3. wait for 5 retries, each 2 sec apart when the file is locked
4. prompt user if the waiting is timeout.
5. write data to a file
Here is a part of my script which I have no idea whether it works.
my $LOCK_EX= 2;
my $LOCK_UN= 8;
open(DATAFILE, "< Datafile.txt")
|| die &wait(30);
flock(DATAFILE, $FLOCK_EX); # Lock
seek(DATAFILE, 0, 2); # No idea what it is
print DATAFILE "$FieldLn"; # Write Data
...
...
flock(STDOUT, $FLOCK_UN); # Unlock
close(DATAFILE);
return "Update Data ID:$KEY: Update Successfully";
I'm really appreciate for your help.
--
Tommy =P
E-mail & E-Voice Mail: tkho@technologist.com
------------------------------
Date: 24 Jan 1998 01:40:09 GMT
From: "jgaff" <jgaff@_no_spam_technologist.com>
Subject: Is Perl cron-able
Message-Id: <01bd2868$fc2a91c0$25612499@jgaff.earthlink.net>
Here is the story -
HP-UX 10.20 running Perl5 and having difficulty getting a Perl script to
run as a cron job.
??? -
Does Perl have any special considerations when running in cron?
I found no specific references to cron on Perl website FAQ's. The only
thing I came up
with but haven't tried yet is playing with PATH.
Cron man page says cron runs with its own environment variables and the
PATH is /bin:/usr/bin
Perl executable is in /opt/perl5/bin as file named perl.
Will a link take to /usr/bin take care of this?? The normal ksh PATH is
along the lines of
/bin:/usr/bin....../opt/perl/bin....HOME/bin...
Any other obviousnesses that I missed??
Thanx
jgaff
------------------------------
Date: 24 Jan 1998 01:33:46 GMT
From: "jgaff" <jgaff@_no_spam_technologist.com>
Subject: Is Perl cron-able?
Message-Id: <01bd2867$6995a800$LocalHost@jgaff.earthlink.net>
Here is the story -
HP-UX 10.20 running Perl5 and having difficulty getting a Perl script to
run as a cron job.
Question/Comment -
Does Perl have special problems or considerations when running as a cron
job?
I couldn't find anything in the Perl website, and I couldn't find a Perl
newsgroup FAQ.
The cron man page said cron executes from its own environment variables
which include
a PATH of /bin:/usr/bin.
The Perl executable program is in /opt/Perl5/bin. I will try linking that
file to /usr/bin
Will the linked Perl executable program work as a link (hard or soft??)?
Any other obviousnesses that I have missed??
Thanx
jgaff
------------------------------
Date: Sat, 24 Jan 1998 03:58:45 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Is Perl cron-able?
Message-Id: <34ce60e8.10167693@flood.xnet.com>
"jgaff" <jgaff@_no_spam_technologist.com> wrote:
>Here is the story -
>
>HP-UX 10.20 running Perl5 and having difficulty getting a Perl script to
>run as a cron job.
>
>Question/Comment -
>
>Does Perl have special problems or considerations when running as a cron
>job?
>
>I couldn't find anything in the Perl website, and I couldn't find a Perl
>newsgroup FAQ.
>The cron man page said cron executes from its own environment variables
>which include
>a PATH of /bin:/usr/bin.
>The Perl executable program is in /opt/Perl5/bin. I will try linking that
>file to /usr/bin
If the first line of the script has the proper path to perl, it should
run. It does not inherit your login env so the first thing you need
to do is set any and all env variables you need. It also has no
concept of your home (~) so you likely need to use a full paths until
you know where you are (cwd may be different from script location).
While I haven't actually run a perl script as a cron job, it should be
less difficult than running a CGI script as 'nobody'.
>Will the linked Perl executable program work as a link (hard or soft??)?
I typically symlink /usr/bin/perl to /usr/local/bin/perl on my Linux
box so scripts run the same locally or on my ISP. The other way
around (to /usr/bin) should work as well. Hard links only work on the
same filesystem.
>Any other obviousnesses that I have missed??
>
>Thanx
>
>jgaff
David Efflandt/Elgin, IL USA
efflandt@xnet.com http://www.xnet.com/~efflandt/
------------------------------
Date: Fri, 23 Jan 1998 21:35:48 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Logical 'and' in regex?
Message-Id: <kinba6.d9o.ln@localhost>
Jonathan Stowe (Gellyfish@btinternet.com) wrote:
: In article <34C61D6A.5244@netserv.unmc.edu>, ptimmins@netserv.unmc.edu
: says...
: >
: >Chipmunk wrote:
: >>
: >> Eli the Bearded wrote:
: >> >
: >> > has never seen the hip owls book in a bookstore
: >>
[snip]
Hmmm.
Three attributions, yet only one line of quote...
Was that a chorus or something?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 24 Jan 1998 03:29:45 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: multithread perl
Message-Id: <34cd592a.8185449@flood.xnet.com>
Chuck Chiang <ctc@cisco.com> wrote:
>I heard that there has been some work done to make Perl multithreaded.
>Could anyone tell me where to find information about this?
>Please send email directly to me at ctc@cisco.com.
>
>thanks very much
>
>-chuck
I don't know the actual difference between multitasking and
multithreading, but I have run 5 processes at once with 4 pipes
between them in Linux.
The main perl script forked a separate process to feed fifo1, a child
process to pipe fifo2 to the parent, a pipe in from external program1
and another pipe to program2 that output a progress guage to the
screen, all simultaniously.
External program1 was actually connected to both fifo's (stdin/out)
and the main script (stderr progress) while simultaniously running 2
way communication on PPP while everything else was going on.
That certainly is multi-something.
David Efflandt/Elgin, IL USA
efflandt@xnet.com http://www.xnet.com/~efflandt/
------------------------------
Date: Fri, 23 Jan 98 20:15:44 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: nested +?* in regexp
Message-Id: <34c940fb$5$ofn$mr2ice@speaker>
In <6ab2uo$ao4$1@henson.cc.kzoo.edu>, on 01/23/98 at 04:43 PM,
k96rk01@cc.kzoo.edu (Robert J. Kent) said:
+-----
| because the 'C++' has a nested quantifier. how do i work around this?
| moreover, the string is ACTUALLY coming from a file, so i can't just type
| 'C\+\+' even if that WOULD work. which i don't think it would. so, long
| story short: how do i match nested quantifiers in strings?
|
| BTW, i HAVE browsed a couple of faqs to no avail. if there's a section i'm
| missing, PLEASE enlighten me!
+--->8
You missed quotemeta() and the \Q...\E escape.
#!/usr/bin/perl
$testStr = 'C++ is';
$longStr = 'i think C++ is bloated and slow.';
if($longStr =~ /\Q$testStr\E/){
# do "success" case...
}
#proceed with program...
#__end__
--
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)
------------------------------
Date: 23 Jan 1998 18:01:23 -0800
From: inwap@best.com (Smith and O'Halloran)
Subject: Re: Please please help a beginner...
Message-Id: <6abi1j$gg4$1@shell3.ba.best.com>
In article <ewgKm06J9GA.123@upnetnews04>,
Ilia Lobsanov <lobsanov_family@email.msn.com> wrote:
1> ### Open friends database to update record
2> open (DATABASE, ">$database");
3> @lines = <DATABASE>;
Line 2 says to destroy the existing database by truncating it to be
zero bytes long and prepare to write to it. Line 3 days to read from
a filehandle that was openned for writing, which is not what you want.
-Joe
--
INWAP.COM is Joe and Sally Smith, John and Chris O'Halloran and our cats
See http://www.inwap.com/ for "ReBoot", PDP-10, and Clan MacLeod.
------------------------------
Date: Fri, 23 Jan 1998 18:55:46 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Reading persistent logs
Message-Id: <34C94928.22E2A155@5sigma.com>
Something like this perhaps. See the perlfunc man page for seek.
-joseph
die "no filename" unless @ARGV;
open FH, shift or die "couldn't open file: $!";
print <FH>;
for (;;) {
sleep 2; # no busy waiting please
seek FH, 0, 1;
print <FH>;
}
Greg King wrote:
>
> How do you setup a Perl program to look for incoming logs messages going
> to a log file without terminating?
>
> For example : then command tail -f filename [...]s
------------------------------
Date: Fri, 23 Jan 1998 18:56:49 -0800
From: Mike <mhanson@arrowweb.com>
Subject: Server Push Problem
Message-Id: <34C95871.247D@arrowweb.com>
How come this server push program doesn't work? I have it named
nph-mail.cgi but it keeps on giving errors. But i have checked it over
and i can't find anything wrong with it.
print "HTTP/1.0 200 Okay\n";
print "Content-type:
multipart/x-mixed-replace;boundary=processdone\n\n";
print "--processdone\n";
$countall = "0";
$countmail = "0";
$files = "";
chdir($ads_dir);
$ls = `ls $files`;
@ls = split(/\s+/,$ls);
$totalsent = ($#ls + 1);
foreach $displayad (@ls) {
$displayad =~ s/.txt//g;
&openread;
$countall += 1;
if ($mail eq "yes") {
$countmail += 1;
$subject = $INPUT{'meaning'};
$mainmessage = $INPUT{'info'};
# Open The Mail Program
open(MAIL,"|$mailprog -t");
print MAIL "To: $email\n";
print MAIL "From: $youremail\n";
print MAIL "Subject: $subject\n";
print MAIL "$mainmessage\n\n";
close (MAIL);
$percdone = int ($countall / $totalsent);
print "Content-type: text/html\n\n";
print "<table bgcolor=99cccc border=1>";
print "<tr><th bgcolor=efefef>$countmail Messages Sent So
Far!</th></tr>";
print "<tr><th bgcolor=efefef>$percdone\% Complete!</th></tr></table>";
print "\n--processdone\n";
sleep 1;
}
exit;
}
------------------------------
Date: Fri, 23 Jan 1998 19:57:50 -0500
From: Joe Gottman <joegottman@nospam.worldnet.att.net>
Subject: Re: Subroutine prototype puzzlement
Message-Id: <6abek8$ifs@bgtnsc03.worldnet.att.net>
Warren Jones wrote:
>
> I'm trying to write a function with the prototype (\@@), and it
> doesn't work the way I expect. I can't seem to pass in a named
> list (e.g. "@b") as the second argument to such a function.
> Here's a little script that demonstrates the problem:
>
> ------------------------------- snip snip -------------------------------
> #! /usr/local/bin/perl -w
>
> sub foo (\@@) {
> print "count = ", scalar(@_), "\n";
> foreach ( @_ ) {
> print "\t[", defined($_) ? $_ : "UNDEF", "]\n";
> }
> print "\n";
> }
>
> my @a = ( 1, 2, 3 );
> my @b = ( 4, 5, 6 );
> my @c;
>
> foo @a, @b; # Why doesn't this work as expected ?
> foo @a, ( @b ); # This works.
> foo @a, @c = @b; # So does this.
> foo @a, 7, 8, 9; # This works too.
>
> ------------------------------- snip snip -------------------------------
>
> And here's the output from the script (run with perl 5.004_03 under
> Solaris 2.5):
>
> count = 2
> [ARRAY(0xb1aec)]
> Use of uninitialized value at ./foo line 6.
> []
>
> count = 4
> [ARRAY(0xb1aec)]
> [4]
> [5]
> [6]
>
> count = 4
> [ARRAY(0xb1aec)]
> [4]
> [5]
> [6]
>
> count = 4
> [ARRAY(0xb1aec)]
> [7]
> [8]
> [9]
>
> My questions:
>
> 1. Why doesn't @b work as the second parameter to "foo",
> although "@c = @b" works just fine? Passing a literal
> list ( 7, 8, 9 ) works too.
>
> 2. Why the warning about "Use of uninitialized value?"
> If the second parameter is uninitialized, why doesn't
> the test for undefined($_) catch it?
>
> Note also that a function with just (@) for a prototype doesn't
> have this problem.
>
> Thanks in advance for any enlightenment.
When you declare a function
sub foo(\@@)
then call it like foo(@array1, @array2), Perl acts like you did
foo(\@array1, @array2);
on a function with no prototype.
i.e. a reference to the first array is passed. Thus, the first statement
in your subroutine should be something like
my $array_ref = shift;
This takes the first element of @_, the refence to @array1, off @_ and
saves it.
Now @_ consists of all the elements in @array2.
--
Joe Gottman
joegottman@nospam.worldnet.att.net
[Remove nospam to reply]
------------------------------
Date: Fri, 23 Jan 1998 19:34:43 -0800
From: "Aamer Nazir" <nazira@cadvision.com>
Subject: Survival Of perl
Message-Id: <34c9537f.0@news.cadvision.com>
Hi,
I have a question which some people would consider 'dumb, but it is not.I
want to ask all of you people that what is the FUTURE of perl.I mean with
the coming of NT servers and Softwares like FrontPage ,is perl going to
survive.I am asking this question because I want to learn this language but
first of all I would like to know what you people think about the language
and what are its applications.
Thanks in advance,
Aamer Nazir
nazira@cadvision.com
------------------------------
Date: 24 Jan 1998 03:48:05 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Survival Of perl
Message-Id: <6abo9l$3lc$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "Aamer Nazir" <nazira@cadvision.com> writes:
:I have a question which some people would consider 'dumb, but it is not.I
:want to ask all of you people that what is the FUTURE of perl.I mean with
:the coming of NT servers and Softwares like FrontPage ,is perl going to
:survive.I am asking this question because I want to learn this language but
:first of all I would like to know what you people think about the language
:and what are its applications.
My goodness, of course it will! What do you think that that PoBs will use
for power text hackery and sophisticated admin work? Java? BAT files?
Don't be silly.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"If Dennis Ritchie were the man who developed Modula-2 then C would be long forgotten."
--Tarjei Jensen
------------------------------
Date: Fri, 23 Jan 1998 19:30:34 -0500
From: Watch your step <jefpin@bergen.org>
To: "N.A.F. McNelly" <nmcnelly@bu.edu>
Subject: Re: UNIX to %$$@! Win: Script Won't Go
Message-Id: <Pine.SGI.3.95.980123192548.5760A-100000@vangogh.bergen.org>
>$name=<STDIN>;
You may (do) want to chop $name, as it will have a \n at the end.
chop($name = <STDIN>);
>$last=".gif";
>$nme=$name . $last;
>open (GIF,"start.gif") || die ("can't open first gif");
When opening files, always include $! in your die() statement. It will
let you know what the server/computer gave as the error message.
open (GIF,"start.gif") || die ("can't open start.gif ($!)");
>$im = newFromGif GD::Image(GIF);
>close GIF;
>open (GIF,"second.gif") || die ("can't open other gif");
And again...
>$src = newFromGif GD::Image(GIF);
>close GIF;
>$im->copy($src,169,271,0,0,83,116);
>open(OUT,">$nme") || die;
And again... just a die() is too terse (opp. of verbose). Let it tell you
why it can't make a new file.
open(OUT,">$nme") || die ("can't make $nme ($!)");
>binmode (OUT);
>print OUT $im->gif;
>close(OUT);
>print "\n";
>print "There should now be a gif named ";
>chop ($name);
Not necessary anymore since you should have done it up top.
>print "$name";
>print ".gif\n";
>print "in the datef directory"
That could all go on the same line... doesn't have to, though.
/----------------------------------------------------------\
| Take a sad song and make it better. |
| - The Beatles |
\----------------------------------------------------------/
Jeff Pinyan | http://users.bergen.org/~jefpin | jefpin@bergen.org
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
techmaster@mindless.com | jpinyan@sdf.lonestar.org
techie@continuum.eu.org | too many addresses!!!
** I can be found on #perl on irc.ais.net as jpinyan **
- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>$ P+++$>++++ L E--->---- W++$
N++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y?
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
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 1718
**************************************