[10450] in Perl-Users-Digest
Perl-Users Digest, Issue: 4042 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 22 05:04:10 1998
Date: Thu, 22 Oct 98 02:00:19 -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 Thu, 22 Oct 1998 Volume: 8 Number: 4042
Today's topics:
Re: a script to collect information for a web page (Martien Verbruggen)
Re: ActiveState or Gurusamy Sarathy <bill@fccj.org>
Re: Any Chicago Perl Mongers Group? <eashton@bbnplanet.com>
Re: Cool company has Perl jobs! (Danny Aldham)
Count files in a dir SSI or CGI cautious_lurker@my-dejanews.com
Exporter issues <ff@creative.net>
Re: Forks and other Utensils <bill@fccj.org>
Re: grrrrr, why not while(<blah>) <jimbo@soundimages.co.uk>
Re: Has anyone experience of using News::NNTPClient? <tmcguigan@bfsec.bt.co.uk>
Help: CGI.pm basic <g8winter@cdf.toronto.edu>
Re: how to redirect POST parameters ? <bill@fccj.org>
I digress... (Justin Wilde)
Re: I digress... (Martien Verbruggen)
Re: Perl & Y2K - booby trap code <jimbo@soundimages.co.uk>
Re: PERL ADO ODBC <jimbo@soundimages.co.uk>
Perl Book on-line Re: Perl Cookbook - is this th <dariusz@usa.net>
Re: Perl Cookbook - is this the best perl book? <eashton@bbnplanet.com>
Re: Perl Cookbook - is this the best perl book? (Martien Verbruggen)
Re: Perl Cookbook - is this the best perl book? (David Formosa)
Re: Perl Cookbook - is this the best perl book? <ajohnson@gatewest.net>
Re: Perl Cookbook - is this the best perl book? <jimbo@soundimages.co.uk>
Still confused with pattern matching <chi@cybie.com>
Re: Still confused with pattern matching <ff@creative.net>
Re: Still confused with pattern matching (Martien Verbruggen)
Re: Still confused with pattern matching (Martien Verbruggen)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 22 Oct 1998 06:00:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: a script to collect information for a web page
Message-Id: <mSzX1.29$Vs4.144788@nsw.nnrp.telstra.net>
In article <70m98l$kpa$1@ns2.foothill.net>,
ilya@ns1.foothill.net (Ilya) writes:
> #!/usr/contrib/bin/perl -w
-w is good.
You might consider use strict for your programs. It helps tremendously.
> open (LIST, "<list.test"); #open master_list for reading
You should always check the return value of an open:
my $fn = 'list.test';
open(LIST, $fn) || die "Couldn't open $fn for reading: $!"
The file name is in a variable, so that I don't have to type it twice :)
> while ($line = <LIST>) # process every line in list until EOF
This should probably be
while (defined($line = <LIST>))
> {
>
> chop ($line); # delete the last character, newline
chomp is safer, chop cuts off the last character, whether or not it is
a newline. chomp only chops if it is a newline (actually, whatever $/
is set to).
# perldoc -f chomp
> sub get_uname
> {
> print (" Executing get_uname \n");
> open (LOCATION, ">/home/ilya/web/sysinfo/$line/uname.out") || die "cannot open \n";
you check the return value, good. You might want to include $! in the
error message, so you know what exactly went wrong.
> open (TEMP, "remsh $line uname -a |");
But here you don't check the return value. Even in the case of a pipe
open you should check it. You might want to check the entry in
perlfaq8 that talks about this:
# perldoc perlfaq8
/Why doesn't open() return an error when a pipe open fails?
> system ("chmod 755 /home/ilya/web/sysinfo/$line/uname.out ");
perl has a builtin chmod, which does the same thing, but without a
fork and exec.
# perldoc -f chmod
> while (<TEMP>)
> {
> print LOCATION $_; # LOCATION <- $_
> }
> close LOCATION; # flush the buffer and write to the file
> }
You don't close TEMP. Probably not a huge problem, but not clean.
Instead of opening a pipe from uname -a, you could use something like:
my @lines = qx(uname -a);
This way you don't have to worry about open and close.
> sub get_os_version
You might consider defining these subroutines outside of the while
loop. This is mainly a stylistic comment. Right now you have quite a
cluttered program flow, and it takes a bit of paging up and down to
see where your loop starts and where it ends.
> {
> print (" Executing get_os_version \n");
> open (LOCATION, ">/home/ilya/web/sysinfo/$line/os_version.out") || die "cannot open \n";
> open (TEMP, "remsh $line uname -a |");
same comments as above in get_uname. of course, get_uname and
get_os_version do more or less the same thing, except that you use a
different part of what comes back. You might consider just calling
uname -a once, and saving the output of it, as ssugested above with
the qx() operator.
> system ("chmod 755 /home/ilya/web/sysinfo/$line/os_version.out ");
>
> while (<TEMP>)
> {
> print LOCATION $_;
> }
> close LOCATION; # flush the buffer and write to the file
> ##################
>
> open (LOCATION2, "cat /home/ilya/web/sysinfo/$line/os_version.out |");
Useless use of cat :)
open(LOCATION2, "/home/ilya/web/sysinfo/$line/os_version.out") || die
"Couldn't open os_version.out: $!"
All the subroutines basically do the same thing for different
commands, so I won't repeat myself.
> sub get_ioscan_disk
> {
[reformat]
> if ($CHAR != "09")
Use eq for string equality, != for numeric equality.
# perldoc perlop
> {
> open (TEMP, "remsh $line /etc/ioscan -fC disk |");
> }
> else
> {
> open (TEMP, "remsh $line /etc/ioscan -funC disk |");
> }
> open (TEMP, "remsh $line /etc/ioscan -funC disk |");
First you open a pipe to something, based on a condition. Without
doing anything with the pipe, you then reopen that file handle on
something else. One of the two is wrong here.
The following is really all that should be inside the while loop.
> &get_uname;
> &get_bdf;
>
> &get_os_version; # find out what version it is
> @Fld = split(/\./,$VERSION);
> $CHAR = $Fld[1];
>
> if ($CHAR != "09") # on a 9.x, do not run what works only on 10.x
> {
> &get_swlist;
> &get_ioscan_disk;
> }
>
> &get_volume_groups;
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd. | things get worse.
NSW, Australia |
------------------------------
Date: Thu, 22 Oct 1998 00:59:36 -0400
From: Bill Jones <bill@fccj.org>
Subject: Re: ActiveState or Gurusamy Sarathy
Message-Id: <362EBBB8.DD35B260@fccj.org>
Bob N. wrote:
>
> They both have 5.005, so which is better, if either? I see some sneering
> at ActiveState, but it seems to be based on 5.004 or older - the 5.00502
> I've got seems OK.
>
> Any opinions here on this (he says with an evil grin)?
>
> - Bob N.
Is your system POSIX capable?
I have always found that installing Gurusamy Sarathy's first, and
then ActiveStates has proven useful...
But I not completely sane either...
-Sneex- :]
________________________________________________________________________
Bill Jones | FCCJ Webmaster | x3089 | http://webmaster.fccj.org:81
------------------------------------------------------------------------
__ _ RedHat 5.1 Manhatten
/ /(_)_ __ _ ___ __ http://www.apache.org
/ / | | '_ \| | | \ \/ / http://www.redhat.com
/ /__| | | | | |_| |> < http://www.perl.com
\____/_|_| |_|\__,_/_/\_\ http://www.gimp.org
------------------------------
Date: Thu, 22 Oct 1998 05:22:51 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Any Chicago Perl Mongers Group?
Message-Id: <362EBEA2.2F5CB0A0@bbnplanet.com>
Jim Allenspach wrote:
> http://chicago.pm.org/
"Donuts and dancing girls at every meeting?" Really? I must get the
stl.pm guys to join me some night to drive up and join y'all. :) This
could be fun. I'm laughing just thinking of the possibilities.
Beware. MarsNeedsWomen.pm is coming soon to a .pm near you. Be Afraid.
e.
After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia. - U. Eco -
------------------------------
Date: 17 Oct 1998 13:33:01 GMT
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: Cool company has Perl jobs!
Message-Id: <70a6ad$7e0$1@lennon.postino.com>
X-Newsreader: TIN [version 1.2 PL2]
Scratchie (upsetter@ziplink.net) wrote:
: You know what this means, don't you... with the general superiority of
: Perl, combined with its "buzzword" status. It won't be too long before MS
: decides they need to include it with Windows.
: Unfortunately, it will probably be a MS-designed hack-job, incompatible
: with standard perl releases, but with OLE built in....
I believe that MS paid Activestate to do the port of Perl to Win32,
(which is now being rolled into the standard dist), and Perl5 is included
in the Resource Kit that MS sell as an add-on to NT.
--
Danny Aldham SCO Ace, MCSE, JAPH, DAD
Field Service Manager BCTel Systems Support
7000 Lougheed Hwy, Burnaby BC (604) 444-8949
------------------------------
Date: Thu, 22 Oct 1998 07:41:09 GMT
From: cautious_lurker@my-dejanews.com
Subject: Count files in a dir SSI or CGI
Message-Id: <70mnil$8ha$1@nnrp1.dejanews.com>
Does anybody know of a SSI or CGI that will count the number of files in a dir
[and sub dir's] and put the result in html.
The cgi would work better for me it would only have to be run once or twice a
day [by cron]
Thanks
C_L
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 21 Oct 1998 23:30:38 -0700
From: Farhad Farzaneh <ff@creative.net>
Subject: Exporter issues
Message-Id: <362ED121.7C0ED3FB@creative.net>
Hello,
I'm trying to use exporter to export from a sub-module. That is,
assume the module a.pm that lives in direcotry A.
Here is file a.pm:
package a;
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(suba);
sub suba {
1;
}
1;
and the calling module:
use A::a;
suba();
This seems to bomb with the error:
# Undefined subroutine &main::suba called.
However, if I move a.pm up one level then everything works. Am I doing
something wrong or does Exporter no like to export from submodules?
Thanks
--
Farhad
------------------------------
Date: Thu, 22 Oct 1998 00:55:35 -0400
From: Bill Jones <bill@fccj.org>
Subject: Re: Forks and other Utensils
Message-Id: <362EBAC7.6599FB78@fccj.org>
Jordan Conley wrote:
>
> Luckily enough I am the sys admin...But what do you mean that zero forks
> are safe...I know I have to check the return, but why do you say zero
> forks are safe??
>
> Jordan
>
[12:57am] 9 [/drv3/home/staff/bill]:astro% perldoc -f fork
=item fork
Does a fork(2) system call. Returns the child pid to the parent process
and 0 to the child process, or C<undef> if the fork is unsuccessful.
Note: unflushed buffers remain unflushed in both processes, which means
you may need to set C<$|> ($AUTOFLUSH in English) or call the
autoflush()
method of IO::Handle to avoid duplicate output.
If you fork() without ever waiting on your children, you will accumulate
zombies:
$SIG{CHLD} = sub { wait };
There's also the double-fork trick (error checking on
fork() returns omitted);
unless ($pid = fork) {
unless (fork) {
exec "what you really wanna do";
die "no exec";
# ... or ...
## (some_perl_code_here)
exit 0;
}
exit 0;
}
waitpid($pid,0);
See also L<perlipc> for more examples of forking and reaping
moribund children.
Note that if your forked child inherits system file descriptors like
STDIN and STDOUT that are actually connected by a pipe or socket, even
if you exit, the remote server (such as, say, httpd or rsh) won't think
you're done. You should reopen those to /dev/null if it's any issue.
HTH,
-Sneex- :]
________________________________________________________________________
Bill Jones | FCCJ Webmaster | x3089 | http://webmaster.fccj.org:81
------------------------------------------------------------------------
__ _ RedHat 5.1 Manhatten
/ /(_)_ __ _ ___ __ http://www.apache.org
/ / | | '_ \| | | \ \/ / http://www.redhat.com
/ /__| | | | | |_| |> < http://www.perl.com
\____/_|_| |_|\__,_/_/\_\ http://www.gimp.org
------------------------------
Date: 22 Oct 1998 07:40:11 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: grrrrr, why not while(<blah>)
Message-Id: <uiuhdgkvo.fsf@jimbosntserver.soundimages.co.uk>
Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> writes:
>
> Heh. /me passes the meds and mikey mouse ears around the group. I am
> HappyFunBall afterall. An oxymoron by any other name. Now, go get your
> gun and shoot everyone in your office. See, that's much better isn't it?
> ;)
>
Yes. :)
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: 22 Oct 1998 08:30:29 GMT
From: "Tiernan Mc Guigan" <tmcguigan@bfsec.bt.co.uk>
Subject: Re: Has anyone experience of using News::NNTPClient?
Message-Id: <01bdfd95$eb194c20$67429284@Avatar>
Brad Murray <murrayb@vansel.alcatel.com> wrote in article
<ud87lx18a.fsf@vansel.alcatel.com>...
> tmcguiga@my-dejanews.com writes:
>
> > But from the documentatiom to this module I'm told it is an error to
attempt
> > to select a non-existent news group. Should I be using another method?
> >
>
> You could use Net::NNTP and the list() command to build an array of legal
> newsgroups, and use that as your checklist before attempting to select a
> group.
I've considered this, but the script runs frequently - fetching an entire
list each time is too much overhead. I concede that I could introduce state
(only do this once a day and save the list to a file), but I wish to see
all my options first.
------------------------------
Date: Wed, 21 Oct 1998 23:11:37 -0400
From: Tungyat Wong <g8winter@cdf.toronto.edu>
Subject: Help: CGI.pm basic
Message-Id: <362EA269.54B598C0@cdf.toronto.edu>
Hi,
I created a very simple script:
use CGI;
$query = new CGI;
if ($query->param('mo')) {
$mode=$query->param('mo')
}
print "$mode";
which works just fine in consolde. But it doesn't work when I point my
browser to
http://localhost/cgi-bin/test.pl?mo=tutor
Other program without using CGI.pm module work just fine..
Any help is appreciate..
------------------------------
Date: Thu, 22 Oct 1998 01:09:46 -0400
From: Bill Jones <bill@fccj.org>
Subject: Re: how to redirect POST parameters ?
Message-Id: <362EBE1A.7CCD33DD@fccj.org>
flash wrote:
>
> hi all,
>
> do someone know how to redirect an URL with POST parameters ?
>
> I have 2 web pages (so 2 forms) for 2 search engines. I want to POST
> the parameters to the same CGI perl.
>
> Depending on these parameters, I would like to rePOST to another CGI.
> Sometimes to people.pl, sometimes to contents.pl .
>
> I can do the redirection but I loose the POST !
>
> I think redirect() ( CGI.pm ) can help me, but I still loose the POST
> !!!
>
> I'm using Perl 5.00404, and CGI.pm 2.36.
>
> Do u have an idea ?
>
> Thanks, flash
Look into LWP modules...
--
________________________________________________________________________
Bill Jones | FCCJ Webmaster | x3089 | http://webmaster.fccj.org:81
------------------------------------------------------------------------
__ _ RedHat 5.1 Manhatten
/ /(_)_ __ _ ___ __ http://www.apache.org
/ / | | '_ \| | | \ \/ / http://www.redhat.com
/ /__| | | | | |_| |> < http://www.perl.com
\____/_|_| |_|\__,_/_/\_\ http://www.gimp.org
------------------------------
Date: Wed, 21 Oct 1998 23:35:59 -0600
From: jwilde@openskies.com (Justin Wilde)
Subject: I digress...
Message-Id: <362EC43E.19A64117@openskies.com>
As a guy new to Perl, I find myself constantly digressing to the
most basic coding conventions while programming in Perl. I don't think
I'm taking advantage of Perl like I could.
Is there a condensed/simpler/cleaner/more-efficent way to do the
following? Sure seems like a lot of code to do something so
straightforward.
if ( length ( $intMonth ) eq 1 ) {
$intMonth = "0$intMonth";
}
Thanks for helping the newguy.
------------------------------
Date: Thu, 22 Oct 1998 06:08:16 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: I digress...
Message-Id: <kZzX1.36$Vs4.144788@nsw.nnrp.telstra.net>
In article <362EC43E.19A64117@openskies.com>,
jwilde@openskies.com (Justin Wilde) writes:
> if ( length ( $intMonth ) eq 1 ) {
> $intMonth = "0$intMonth";
> }
$intMonth = sprintf("%02d", $intMonth);
# perldoc -f sprintf
# perldoc -f printf
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd. | I can ask him what he meant - Steven
NSW, Australia | Wright
------------------------------
Date: 22 Oct 1998 09:47:48 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <uems1geyz.fsf@jimbosntserver.soundimages.co.uk>
Randal Schwartz <merlyn@stonehenge.com> writes:
>
> There was *nothing* wrong with the Pink camel's description. If I
> read a book on brain surgery, I do *not* expect the book to describe
> basic suture techniques, even though without that, the book is useless
> to me. Books are written to a *specific* audience.
>
I always wondered what to do after I'd removed the patients frontal
lobes! Well, at last! All my patients will be saved!
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: 22 Oct 1998 09:39:44 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: PERL ADO ODBC
Message-Id: <ug1chgfcf.fsf@jimbosntserver.soundimages.co.uk>
jhardy@cins.com (John Hardy) writes:
> and have read is it changes quite frequently. Also ADO (OLE) is faster then
Firstly, join the Win32* mailing list(s) at www.activestate.com, this
will get you the Win32 specific info you need. In addition, there is a
decent Win32 FAQ referenced there as well.
Second, you have already answered your question. The way you get it to
work is you use Win32::OLE to create an ADO object, you know, a
Connection object and a Command object and a Recordset object. Just
like ASP. Then you tell the Recordset object to do it's thing. The
results of your query are now in the Recordset which you manipulate
just like using ASP. You know, you invoke the various Recordset
methods to access the results, modify the results, update the
database, etc.
The code example(s) you require have been posted before. Do a search
on www.dejanews.com and you will find many posts relating to OLE
et. al. DBI will probably be a better bet in the long run because it
does not require the continued devotion to MS that ADO requires. If
you don't mind eating from that poarticular trough, then ADO will do
the job.
Here is a copy of such a post. In future, serch before you post. All
the questions have been asked and answered before.
Author: Jan Dubois
Email: jan.dubois@ibm.net
Date: 1998/09/29
Forums: comp.lang.perl.misc
Here is one of my standard samples to use ADO from Perl. If you have further
questions, don't hesitate to ask them on the Perl-Win32-Database mailing
list (put ADO and/or OLE on the subject line!).
-Jan
use strict;
use Win32::OLE qw(in);
my $Conn = Win32::OLE->new("ADODB.Connection");
$Conn->Open("AdvWorks");
my $RS = $Conn->Execute("SELECT * FROM Orders");
until ($RS->EOF) {
foreach my $Field (in $RS->Fields) {
printf "%-20s: %s\n", $Field->Name, $Field->Value;
}
$RS->MoveNext;
print "\n";
}
$RS->Close;
$Conn->Close;
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: Thu, 22 Oct 1998 08:03:58 GMT
From: Darius Jack <dariusz@usa.net>
Subject: Perl Book on-line Re: Perl Cookbook - is this the best perl book?
Message-Id: <362ED6AE.1D94@usa.net>
Linda Mui wrote:
>
> Larry Rosler wrote:
> >
> > The authors set up a very capable system to handle feedback from a
> > considerable community of reviewers. More could not be expected of them
> > (the authors, that is).
Any chance to read this book or any other on-line.
Give www address if avaliable.
Jack
------------------------------
Date: Thu, 22 Oct 1998 05:16:00 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <362EBD07.C56D105F@bbnplanet.com>
OK. I'll bite even though I know the guy was a total troll.
O'Reilly has my everlasting love and devotion since the day the TeX book
came out. No technical publisher could ever compare to the technical
excellence nor their always, and I do mean _always_, publishing their
errata. Every book is without peer. There are a few books I have thought
were a bit more authoritative, but, indeed, few I can think of at the
moment. I have zero IDG books on my bookshelf. I buy ORA books for
reasons of style, excellence, content and to support their mission of
technical excellence. It is almost a religious experience. The Ram book
colophon was so amusing! Where else could you get that? Though we are
wondering why vi needs a 6th ed. ;)
/me raises a good single malt in the direction of Tim O'Reilly. Here
here!, here my good man, thank _you_ for being such an incredible
publisher and supporter of Perl. *smooch*. I highly doubt the language
would be what it is today without your support and the conferences. And
thanks to the authors who have worked so hard to write such great tomes
that should be on everyones bookshelf and have helped ORA see the way of
the Force. And to the under-appreciated editors, et al. who really rule
the day and make it all happen. Oh geez, I'm getting all squishy now. No
one, can diminish the authority that ORA has in the technical publishing
market. No one. Not this troll or anyone else.
e.
After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia. - U. Eco -
------------------------------
Date: Thu, 22 Oct 1998 05:33:19 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <zszX1.24$Vs4.128786@nsw.nnrp.telstra.net>
In article <362E3722.31C7@oreilly.com>,
Linda Mui <lmui@oreilly.com> writes:
> I hope Mr. (Ms.?) Jenkins has been sending us errata
> so we can incorporate them into the next printing.
It's unlikely that you'll receive a list of errata from this person.
Some people like to help fix things, some people just like to whine
about it.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In the fight between you and the world,
Commercial Dynamics Pty. Ltd. | back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: 22 Oct 1998 16:15:46 +1000
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <70miii$s6i$1@godzilla.zeta.org.au>
In <362EBD07.C56D105F@bbnplanet.com> Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> writes:
>OK. I'll bite even though I know the guy was a total troll.
>O'Reilly has my everlasting love and devotion since the day the TeX book
>came out.
Isn't the TeX Book published by Addason and Wesley?
--
Please excuse my spelling as I suffer from agraphia. See the URL in my
header to find out more.
------------------------------
Date: Thu, 22 Oct 1998 02:22:01 -0500
From: Andrew Johnson <ajohnson@gatewest.net>
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <362EDD19.2E452AB8@gatewest.net>
David Formosa wrote:
!
[snip]
! >O'Reilly has my everlasting love and devotion since the day the TeX book
! >came out.
!
! Isn't the TeX Book published by Addason and Wesley?
I would venture to guess that the use of 'the TeX book' there was not
meant to refer to the book entitled 'The TeXbook' by Addison Wesley,
but rather O'Reilly's one book on TeX (Making TeX Work) --- hence, in
conjunction with O'Reilly, the phrase 'the TeX book' seems relatively
unambigous ... this is a Perl group after all, context is important
:-)
regards
andrew
------------------------------
Date: 22 Oct 1998 09:11:51 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <uhfwxggmw.fsf@jimbosntserver.soundimages.co.uk>
Tom McGee <tmcgee@bondmarkets.com> writes:
> Errors or not, it's already paid for itself.
>
My experience exactly. I bought the book and in less than two hours it
had provided me with the necessary insight and instruction to solve a
particular problem that for no apparent reason had decided to crop up.
Sicne then I have used it repeatedly.
Thank you Tom And Natahn. :)
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: Wed, 21 Oct 1998 23:09:44 -0700
From: Chi Yu <chi@cybie.com>
Subject: Still confused with pattern matching
Message-Id: <362ECC28.114B1ED9@cybie.com>
Hi All,
I'm baffled with this bit of code. I'm expecting to pattern match on
digits 0-9 or fail the edit, but a value of "X" matches!
$mls = "X";
if ($mls =~ /[0-9]*/) {
$mls = "matched"; }
else {
$mls = "not-matched"; }
print "$mls\n";
OUTPUT ==> matched
I expect the code to not match but it does match! What's wrong with the
code?
Thanks, Chi Yu
------------------------------
Date: Wed, 21 Oct 1998 23:33:16 -0700
From: Farhad Farzaneh <ff@creative.net>
To: Chi Yu <chi@cybie.com>
Subject: Re: Still confused with pattern matching
Message-Id: <362ED1BE.14AEABE1@creative.net>
Hi,
The problem is that the '*' specifier will match 0 or more times. If you want
to match a digit at least once use the '+' specifier.
if ($mls =~ /[0-9]+/) {
$mls = "matched"; }
else {
$mls = "not-matched"; }
Chi Yu wrote:
>
> Hi All,
>
> I'm baffled with this bit of code. I'm expecting to pattern match on
> digits 0-9 or fail the edit, but a value of "X" matches!
>
> $mls = "X";
> if ($mls =~ /[0-9]*/) {
> $mls = "matched"; }
> else {
> $mls = "not-matched"; }
>
> print "$mls\n";
>
> OUTPUT ==> matched
>
> I expect the code to not match but it does match! What's wrong with the
> code?
>
> Thanks, Chi Yu
------------------------------
Date: Thu, 22 Oct 1998 06:42:27 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Still confused with pattern matching
Message-Id: <ntAX1.54$Vs4.144788@nsw.nnrp.telstra.net>
In article <362ED1BE.14AEABE1@creative.net>,
Farhad Farzaneh <ff@creative.net> writes:
> if ($mls =~ /[0-9]+/) {
You realise that this does the same as
if ($mls =~ /\d/)
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | A Freudian slip is when you say one
Commercial Dynamics Pty. Ltd. | thing but mean your mother.
NSW, Australia |
------------------------------
Date: Thu, 22 Oct 1998 06:29:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Still confused with pattern matching
Message-Id: <zhAX1.50$Vs4.144788@nsw.nnrp.telstra.net>
In article <362ECC28.114B1ED9@cybie.com>,
Chi Yu <chi@cybie.com> writes:
> I'm baffled with this bit of code. I'm expecting to pattern match on
> digits 0-9 or fail the edit, but a value of "X" matches!
>
> $mls = "X";
> if ($mls =~ /[0-9]*/) {
This means:
$mls contains 0 or more characters in the class [0-9]
Since the string 'X' contains zero characters in that class, it will
match.
Depending on what you want:
Match strings that contain nothing but digits: /^\d+$/
Match strings that contain nothing or nothing but digits: /^\d*$/
Match strings that contain at least one digit: /\d/
Note that \d is the same as [0-9].
# perldoc perlre
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
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 4042
**************************************