[15702] in Perl-Users-Digest
Perl-Users Digest, Issue: 3115 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 21 21:10:21 2000
Date: Sun, 21 May 2000 18:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958957812-v9-i3115@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 21 May 2000 Volume: 9 Number: 3115
Today's topics:
Re: regexes *sigh* damn I hate these things <nospam@devnull.com>
Re: regexes *sigh* damn I hate these things <godzilla@stomp.stomp.tokyo>
Re: regexes *sigh* damn I hate these things <nospam@devnull.com>
Re: regexes *sigh* damn I hate these things <anmcguire@ce.mediaone.net>
Re: regexes *sigh* damn I hate these things (Bart Lateur)
Re: REGEXP newbie question <john@digitalmx.com>
Re: Sendmail problem! <tina@streetmail.com>
Re: sorting a list of mixed numbers and text as in perl <nospam@devnull.com>
Re: the use of $_ <elaine@chaos.wustl.edu>
Re: the use of $_ <elaine@chaos.wustl.edu>
tough naming problem (jkroger)
Re: tough naming problem (jkroger)
Re: valid email address (Bart Lateur)
Re: valid email address <john@digitalmx.com>
Re: What's this line which Perl added to AUTOEXEC.BAT? <john@digitalmx.com>
Re: What's this line which Perl added to AUTOEXEC.BAT? <waldo700NOwaSPAM@aol.com.invalid>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 May 2000 22:43:40 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <8g9oqs$m2e$0@216.155.32.172>
In article <392af436.3539971@news.skynet.be>, bart.lateur@skynet.be (Bart
Lateur) wrote:
| Andrew N. McGuire wrote:
|
| >while (<DATA>)
| >{
| > print "$1\n"
| > if m|^Rating: \(1-10\) (\d*?\.*[05]*)</p><!--.*?-->|;
| >}
|
| Too specific to my taste.
|
| m|Rating: *\(1-10\) *([\d\.]+)| and print "$1\n";
^
why the * right there? I'm allso curious as to why the * is set <before> the ()
and not after in both instances.. does that change how the string gets parsed by
the regex?
Aside:
I also notice that no one followed up to the changed thread marked 'Update' that
I posted, but plenty of people are willing to post garbage and waste of
bandwidth to someone else's posting in this thread instead of just dealing with
my question.. this is somewhat disappointing.
I've been here long enough that I don't need any reminders from the regulars to
look before I perl -e.
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Sun, 21 May 2000 16:00:08 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <39286A78.808E2D99@stomp.stomp.tokyo>
Sue Spence wrote:
> "Godzilla!" says...
> >Sue Spence wrote:
> > I test all of my code, harshly, before posting,
> > knowing some of you less-than-skilled people will
> > be all over it like flies on fresh mule manure.
> You know, I can't quite agree with this, but
> I've already made my main concern known in my
> other posting. I'm not really into personal
> slanging matches in technical newsgroups, so
> don't imagine you'll get me down to your own
> level like this.
As a child, about knee high to an Oklahoma
Cotton Mouth, one of my, one of us kid's chores,
was shoveling out mule manure from our corral,
to help keep our priceless, life saving mules
from coming down with The Bangs in their hooves.
Without our two plow mules, two being an indicator
of being wealthy farmers, surely we would go hungry.
Musing instead of tending my chores, I watch a
big barnyard fly, fattened on a cuisine of
fresh mule manure, trying to fly. In frustration,
after numerous attempts to take to blue sky, this
fly smartened up and crawled up a pitch fork handle,
whereupon, he leaped with hopes of flying. No luck.
Splat. Face first back into this mule manure he went.
Barefoot and hungry scrawny, I thought to myself,
"Ya know, when yall done know your full of manure,
ya shouldn't go and fly off the handle."
My Perl code provided works with absolute perfection,
is eloquently simplistic and written in such old
fashion Plain English, almost all understand what it
does at first glance.
Who needs an expensive fancy air conditioned John Deere
when you can attain nirvana busting dirt clods bare foot,
plodding and plowing along behind two ornery mules, both
of which are slinging smelly mule sweat on you for cooling,
under a sweltering Oklahoma sun? Simplicity is survival.
Godzilla!
------------------------------
Date: 21 May 2000 23:32:56 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <8g9rn8$kv4$0@216.155.32.172>
In article <x7u2fse4ch.fsf@home.sysarch.com>, Uri Guttman <uri@sysarch.com>
wrote:
| TW> ok you're losing me again.
|
| what if the number you matched is 0.0? then testing $var for truth will
| fail and you lose. you test the actual match operation to see if you
| matched. then you can assign $1 knowing it has something. in fact i have
| never seen code like your line above. it is not clean and can break.
|
| your regex looks ok but it is busy. mine would work but is much
| simpler. in the regex world simpler is usually better.
ok. I get ya now.
| TW> | if ( /\)\s*(\d+\.\d*)</ ) {
| TW> |
| TW> | there are many variations of the regex itself. in fact you don't
| need
| TW> | the outer Rating match either. given your string that one will
| match
| TW> | there just fine.
|
| TW> problem. there may be other instances of numbers IN that html file,
| and I need
| TW> to be absolutely certain that it matches the number from the ratings
| line.
|
| then make it one longer match:
|
| if ( /Ratings:.*\)\s*(\d+\.\d*)</ ) {
|
| that will grab a number following a close paren which has Ratings:
| somewhere before it. no need to do 2 matches when one will do. simplify.
I've simplified it *greatly* now to this based on something someone else posted:
foreach (@filedata) {
#search the lines and look for the "Rating:" phrase
if (m|Rating: *\(1-10\) *([\d\.]+)|) {
# dump it into the hash, and skip the rest of the file, since we have what we
need
$listing{$filez} = $1;
next FILE
}
}
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Sun, 21 May 2000 18:59:36 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <Pine.LNX.4.20.0005211852010.18426-100000@hawk.ce.mediaone.net>
On 21 May 2000, The WebDragon wrote:
+ In article <392af436.3539971@news.skynet.be>, bart.lateur@skynet.be (Bart
+ Lateur) wrote:
+
+ | Andrew N. McGuire wrote:
+ |
+ | >while (<DATA>)
+ | >{
+ | > print "$1\n"
+ | > if m|^Rating: \(1-10\) (\d*?\.*[05]*)</p><!--.*?-->|;
+ | >}
+ |
+ | Too specific to my taste.
+ |
+ | m|Rating: *\(1-10\) *([\d\.]+)| and print "$1\n";
+ ^
+ why the * right there? I'm allso curious as to why the * is set <before> the ()
+ and not after in both instances.. does that change how the string gets parsed by
+ the regex?
Well, I do not know why he said my regex was to specific, I thought it
was good to be specific?!? I am not a regex guru though... As to why
the * is before the (), he is saying "0 or more spaces", making the
space optional. Although this could be more cleary ( at least to me )
'\s*'.
+ Aside:
+ I also notice that no one followed up to the changed thread marked 'Update' that
+ I posted, but plenty of people are willing to post garbage and waste of
+ bandwidth to someone else's posting in this thread instead of just dealing with
+ my question.. this is somewhat disappointing.
Well, you can't blame me (well now you can ;^)... As for people posting
garbage, people will be people. There are too many trolls here now.
+ I've been here long enough that I don't need any reminders from the regulars to
+ look before I perl -e.
Amen. I does not take long to learn, provided you keep an open mind
and a willingness to do some research for yourself. There are those
here who do neither (and they are now going to start getting scored
down).
Cheers,
anm
--
/*-------------------------------------------------------.
| Andrew N. McGuire |
| anmcguire@ce.mediaone.net |
`-------------------------------------------------------*/
------------------------------
Date: Mon, 22 May 2000 00:00:11 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <392c7827.11722532@news.skynet.be>
The WebDragon wrote:
> | Too specific to my taste.
> |
> | m|Rating: *\(1-10\) *([\d\.]+)| and print "$1\n";
> ^
>why the * right there? I'm allso curious as to why the * is set <before> the ()
>and not after in both instances.. does that change how the string gets parsed by
>the regex?
Because, if you're not sure about the numbers, then they could be
manually entered, and therefore , you're not too sure about the numbers
of spaces either. Tabs are rare in HTML pages, or I would have used \s*
instead.
p.s. I'll have a look at your "update" next.
--
Bart.
------------------------------
Date: Sun, 21 May 2000 17:24:50 -0700
From: John Springer <john@digitalmx.com>
Subject: Re: REGEXP newbie question
Message-Id: <B54DCC62.B10%john@digitalmx.com>
in article 392812f4.39129365@sointnews, Dr. Smith at mosher@amdocs.com wrote
on 5/21/00 9:54 AM:
> Can anyone give me a nice regular expression that will give a match,
> only if the string entered is a leagal UNIX user name?
I think you'll get that with just /^\w+$/
\w means unix "words", which are A-Za-z0-9_.
Try this:
while (1){
print "Try this: ";
chomp($_=<>);
if ( /quit/){exit;}
print /^\w+$/?"Matched":"Didn't","\n";
}
--
John Springer
Watching the rain come down in Portland.
Pondering perl.
Everything's green and fresh.
------------------------------
Date: Sun, 21 May 2000 20:17:11 -0400
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Sendmail problem!
Message-Id: <39287C86.2A29C115@streetmail.com>
hi,
Penpal International wrote:
> open (MAIL, "|$mailprog -t");
> print MAIL "To: $line\n";
> print MAIL "From: webmaster\@searchystats.com(SearchyStats)\n";
> print MAIL "Subject: SearchyStats News & Updates\n";
> Every time it changes searchystats.com to the hostname my machine is
> running on. How can I force it to send the right address at the From
> field?
that's a sendmail, not a perl question, but anyway:
try the -r switch.
(man sendmail)
but you can only do this if you are root; else there will be
a warning header in the email like "user@host set "From" to ..."
tina
--
__ tinamue@gmx.net __| _ enter the
http://user.berlin.de/~tina.mueller | __| |___ ___ _ _ ___
____ tina's moviedatabase ____| / _` / _ \/ _ \ '_(_-< of
__search & add comments or reviews__| \__,_\___/\___/_| /__/ perception
------------------------------
Date: 22 May 2000 00:45:25 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: sorting a list of mixed numbers and text as in perldoc
Message-Id: <8g9vv5$pai$0@216.155.32.172>
In article <slrn8idf1j.tkm.tjla@thislove.dyndns.org>, tjla@guvfybir.qlaqaf.bet
(Gwyn Judd) wrote:
| The only trouble with this is that it produces a whole bunch of warnings
| about undefined variables when run under -w, so with a bit of hacking I
| came up with this version which does plus it's (slightly) more
| configurable I guess.
|
| #!/usr/bin/perl -w
|
| use POSIX qw(INT_MAX);
|
| @old = qw(hi low 1 2 3 yo what's up dawg?);
|
| # set this to INT_MAX to sort text before numbers or set to 0 to sort
| # numbers before text
| $text_first = INT_MAX;
|
| @new = map { $_->[0] }
| sort { $b->[1] <=> $a->[1]
| ||
| $a->[2] cmp $b->[2]
| } map { [$_, m/(\d+)/ ? $1 : $text_first, uc($_)] } @old;
|
| print join " ", @old;
| print "\n";
| print join " ", @new;
|
well, this outputs
===
hi low 1 2 3 yo what's up dawg?
dawg? hi low up what's yo 3 2 1
===
what if you wanted the output to be:
====
dawg? hi low up what's yo 1 2 3
====
how would you change that?
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Mon, 22 May 2000 00:05:03 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: the use of $_
Message-Id: <B54DF1EE.46FB%elaine@chaos.wustl.edu>
in article 39281AD2.8B439E31@stomp.stomp.tokyo, Godzilla! at
godzilla@stomp.stomp.tokyo quoth:
> Perl 4 is the foundation of Perl 5, yes?
No, actually. Larry practically rewrote Perl5 from scratch...but this
depends too on your definition of 'foundation'. But...4 and 5 are worlds
apart.
e.
------------------------------
Date: Mon, 22 May 2000 00:07:46 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: the use of $_
Message-Id: <B54DF292.46FC%elaine@chaos.wustl.edu>
in article 958938961.716827@shelley.paradise.net.nz, Tintin at
you.will.always.find.him.in.the.kitchen@parties quoth:
> Please name me just one current Operating System that comes with Perl 4.
HP-UX though it isn't installed with the OS by default.
e.
------------------------------
Date: Sun, 21 May 2000 18:10:10 -0400
From: jkrogerSPAMBLOCKER@earthlink.net (jkroger)
Subject: tough naming problem
Message-Id: <jkrogerSPAMBLOCKER-2105001810100001@tritone.csbmb.princeton.edu>
Hello, I'm having some trouble with dereferencing variable names.
A simplified version of my problem is:
I have five columns in a file, the contents of which I don't know but only
know the format of:
a f m q 1
b g n r 2
c h o s 3
. . . . .
. . . . .
. . . . .
This is read into five arrays, arya, aryf, arym, aryq, ary1. I need to,
for example, put the third value of ary1 into the eighth slot of an array
whose name is the second element of arya (c[7] = ary1[2]). But I don't
know the values of arya in advance.
Whether or not such has already been created, how do I refer to:
The seventh slot in an array whose name is the second element of arya?
I tried ${arya[1]}[2], "${arya[1]}[2]", "${arya[1]}"[2], and setting a
variable $tmp to the value of $arya[1] and using ${tmp}[2], "${tmp}[2],
etc... None of these work.
Then, how do I refer to the fourth element in and array whose name is the
first element in the above array (arya[7[1[4]]])? I haven't tried anything
because since I can't figure out the single dereference above, I have no
idea how to do the double dereferencing required here.
I could also ask about how to name the fifth element of an array whose
name is the element in the array described in the previous sentence. This
would be a third-degree dereference. In general, how does one name an
element in an array when the array's name is an element of another array,
whose name is an element of another array, whose name is an element of
another array, and so on (assuming all the arrays' names are generated on
the fly from data and not known in advance)?
I have looked through "Learning...," "Programming...," and "Perl
Cookbook." If it is there I have seen it.
Thanks in advance for any help,
Jim
------------------------------
Date: Sun, 21 May 2000 18:22:01 -0400
From: jkrogerSPAMBLOCKER@earthlink.net (jkroger)
Subject: Re: tough naming problem
Message-Id: <jkrogerSPAMBLOCKER-2105001822010001@tritone.csbmb.princeton.edu>
>
> I have looked through "Learning...," "Programming...," and "Perl
> Cookbook." If it is there I have seen it.
>
Sorry, that should read, "If it is there I have not seen it."
Thanks
Jim
--
please watch out for SPAM_BLOCKER
------------------------------
Date: Sun, 21 May 2000 23:44:00 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: valid email address
Message-Id: <392b6625.7112622@news.skynet.be>
Neil Kandalgaonkar wrote:
>Finaly, the reliably ingenious Abigail has written a module which
>uses Parse::RecDescent to check addresses against RFC 822.
>It's slow but it seems to work, although
>the test script shows it misses a few cases. Running the test script
>with --debug shows just how insanely complex the spec is.
Now I'm curious. Examples, please?
--
Bart.
------------------------------
Date: Sun, 21 May 2000 17:55:28 -0700
From: John Springer <john@digitalmx.com>
Subject: Re: valid email address
Message-Id: <B54DD38F.C2E%john@digitalmx.com>
while (1){
print "Try Me: ";
$email=<>;
chomp $email;
if ($email=~/quit/){exit;}
print "$email is ", &Valid_Email($email)?"Valid\n":"Not Valid\n";
}
#######
sub Valid_Email{
my $email=shift;
if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/ ||
($email !~ /^.+\@localhost$/ &&
$email !~ /^.+\@\[?(\w|[-.])+\.[a-zA-Z]{2,3}$/)) {
return 0;
}
return 1;
}
It returns 1 or 0, depending on whether or not it looks right.
if (!Valid_Email($email)){print "A pox on you.\n";}
Of course, if someone enters something bogus and you tell them so, they will
then enter something like "bill.gates@ripoff.org" and it will look just
fine.
--
John Springer
Watching the rain come down in Portland.
Pondering perl.
Everything's green and fresh.
------------------------------
Date: Sun, 21 May 2000 17:33:32 -0700
From: John Springer <john@digitalmx.com>
Subject: Re: What's this line which Perl added to AUTOEXEC.BAT?
Message-Id: <B54DCE6B.B12%john@digitalmx.com>
in article 391fff59.64553886@news.rmi.net, William Herrera at
posting.account@lynxview.com wrote on 5/15/00 6:51 AM:
> Windows has many vestiges of its command-line DOS heritage. One of the is that
> if you change the PATH stsement before Windows finishes loading, as
> ActiveState
> 5.6 does, Windows will not be able to find WIN.COM. Manually add that perl
> directory to your path or as Stwe says, change it to
> SET PATH=C:\Perl\bin;%PATH%\
Can you believe this is the OS that took over the world.
I feel a vomit coming on.
--
John Springer
Watching the rain come down in Portland.
Pondering perl.
Everything's green and fresh.
------------------------------
Date: Sun, 21 May 2000 17:52:49 -0700
From: bjanko <waldo700NOwaSPAM@aol.com.invalid>
Subject: Re: What's this line which Perl added to AUTOEXEC.BAT?
Message-Id: <1071a7a9.2bf1ce74@usw-ex0105-034.remarq.com>
Thanks for believing me. That's exactly what happened: Windows
could not find "win.com" thanks to ActivePerl. Some people
doubt this. Oh, well.
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 3115
**************************************