[15705] in Perl-Users-Digest
Perl-Users Digest, Issue: 3118 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 22 06:10:42 2000
Date: Mon, 22 May 2000 03:10:21 -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: <958990220-v9-i3118@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 22 May 2000 Volume: 9 Number: 3118
Today's topics:
Re: regexes *sigh* damn I hate these things <uri@sysarch.com>
Re: regexes *sigh* damn I hate these things (Gwyn Judd)
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 <sue@pennine.com>
Re: regexes *sigh* damn I hate these things <nospam@devnull.com>
Re: REGEXP newbie question <nospam@devnull.com>
Re: SETUID problem (maybe lame) <gellyfish@gellyfish.com>
Re: sorting a list of mixed numbers and text as in perl <nospam@devnull.com>
Re: Suggest an approach for HTML Form submission <nospam@devnull.com>
Re: the use of $_ <elaine@chaos.wustl.edu>
Re: the use of $_ <godzilla@stomp.stomp.tokyo>
Re: the use of $_ <elaine@chaos.wustl.edu>
Re: the use of $_ <nospam@devnull.com>
Re: the use of $_ <uri@sysarch.com>
Re: the use of $_ <you.will.always.find.him.in.the.kitchen@parties>
Re: Untaint URL character class (Neil Kandalgaonkar)
Re: updated : Re: regexes *sigh* damn I hate these thin (Bart Lateur)
Re: Using DBM for simple database? <gellyfish@gellyfish.com>
Re: valid email address <thepoet1@arcormail.de>
Re: valid email address <webmaster@momsathome.on.ca>
Re: valid email address (Sean McAfee)
Re: What's this line which Perl added to AUTOEXEC.BAT? <sue@pennine.com>
Win32::OLE question: translating from VB/VFP (Ben Hambidge)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 22 May 2000 04:17:49 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <x7og5zdxqt.fsf@home.sysarch.com>
>>>>> "TW" == The WebDragon <nospam@devnull.com> writes:
TW> foreach (@filedata) {
TW> #search the lines and look for the "Rating:" phrase
TW> if (m|Rating: *\(1-10\) *([\d\.]+)|) {
TW> # dump it into the hash, and skip the rest of the file, since we have what we
TW> need
TW> $listing{$filez} = $1;
TW> next FILE
you should end statements with ; evn if they are the last one in a
block where it is not needed. it looks better and means one less little
bug to bite when you add code afterwards.
also did you get my point about using last instead of next FILE? last
will exit the line loop and therefore fall thru and do the file loop
again. so there is no need for the FILE label. only use labels when you
must which is not the case here. proper design of loops in perl will
almost eliminate the need for labels.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 22 May 2000 04:35:51 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <slrn8ik2pc.4gt.tjla@thislove.dyndns.org>
I was shocked! How could Godzilla! <godzilla@stomp.stomp.tokyo>
say such a terrible thing:
>Sue Spence wrote:
>
>> I submit that this is not helpful to people, yet your
>> introduction to your code was highly confident.
>> How about coming back with code that will
>> compile, run and provide the right answer?
>
>
>
>I submit you don't know how to run a Perl program.
>As it is, I tested this no less than twenty to
>twenty-five times. Works perfect without failure.
>
>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.
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$input = "
<p>Name: <a href=\"http://www.planetunreal.com/dl/nc.asp?nalicity/
utdm/dm-distinctive.zip\">DM-Distinctive</a><br>
Author:<a href=\"mailto: 9123.2blah\@hotmail.com\">Bastiaan
Frank</a><br>
Rating: (1-10) 9.5</p><!-- add correct image name below here -->
<img align=\"right\" border=\"0\" hspace=\"10\" vspace=\"10\"
width=\"231\" height=\"173\"
src=\"dm-distinctive.jpg\">";
if ($input =~ / ([0-9\.]+)/)
{ $input = $1; }
print $input;
exit;
This outputs "9123.2" not "9.5".
--
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Tomorrow, you can be anywhere.
------------------------------
Date: 22 May 2000 05:06:26 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <8gaf8i$1vm$1@216.155.32.48>
In article <392892CB.8C91536@stomp.stomp.tokyo>, "Godzilla!"
<godzilla@stomp.stomp.tokyo> wrote:
| The WebDragon wrote:
|
| > *cough* what exactly does this have to do
| > with my question and why is it here in my thread? :)
|
|
| I dunno. Ask those others whom appear to
| have their diapers in a knot over my code
| being so simple, yet so perfect. My guess
| is nobody thought to meet your challenge
| with such simplicity and, now, well...
| who knows, guess they are pissed off.
| I sure didn't twist their arms and force
| them to pitch a big conniption fit.
Just curious, but is there any particular reason your linewrapping is so short?
| I've noticed with passing articles your
| solution code is beginning look more like
| what I wrote. Interesting.
Even more interesting to me is how quickly I'm managing to pick things up. I'm
not ready quite yet to do any majorly advanced stuff, but as I learn the tricky
stuff and shortcuts, I'm getting there.
What's frustrating is doing a script for someone's benefit, and while wrestling
over a regex, having them hack their way through the problem using a BASIC like
solution via substr to hack off the last 5 chars of a filename (.html) with
little to no regard for the possibility of there being an .htm file there, when
a regex, properly done, is a more elegant solution (IMHO).
And THEN having them complain that they want to be able to read the code...
which is why he didn't want to use the regex I finally came up with. (when IMHO
if you bothered to take the time to study and learn perl, regexes aren't that
difficult to follow, if commented well, or use of whitespace + comments via the
/x modifier makes things simpler as well.
--
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 22:41:44 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <3928C898.116B9DFD@stomp.stomp.tokyo>
The WebDragon wrote:
> "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> Just curious, but is there any particular reason
> your linewrapping is so short?
Yes there is a reason. Is there a reason
your lines are so long?
> What's frustrating is doing a script for
> someone's benefit....
This is a no-no as a general rule. Anymore I write
scripts only for close personal friends. Those who
don't know programming, never realize how much time
and effort go into writing and rewriting to attain
a decent script.
There is a cure if you have problems. Always include
a password protected FUBAR routine in your code. Up
to you what to do but as a hint, a routine which
wipes all data bases, then writes an imaginative
.htaccess document, can teach good lessons to
those who don't appreciate your efforts. This
is especially true if you include some funnies
for FTP access. However, also keep current backup
copies to restore all, once your friend agrees,
you are in charge of writing your script. This
is the right thing to do, even if agreement
is never had. Being in charge can be good.
Being mean, is never good.
> And THEN having them complain that they want to be
> able to read the code... which is why he didn't want
> to use the regex I finally came up with....
Your thoughts I snipped are logical and valid.
Regex is very difficult to learn and, regex is amongst
the most useful tools available with Perl. I am both
enjoying and learning from this thread of 'yours'.
Much valuable information is being shared with all,
some of which, I have to sit and study for a period to
fully understand and appreciate. Your way of discussing
what is happening and why, is most beneficial.
Always check under your nose though, sometimes a
small simple regex might be hiding there, just
to be ornery.
Godzilla!
------------------------------
Date: 22 May 2000 07:49:06 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <8gaopi$plj$1@216.155.32.48>
In article <x7og5zdxqt.fsf@home.sysarch.com>, Uri Guttman <uri@sysarch.com>
wrote:
| also did you get my point about using last instead of next FILE? last
| will exit the line loop and therefore fall thru and do the file loop
| again. so there is no need for the FILE label. only use labels when you
| must which is not the case here. proper design of loops in perl will
| almost eliminate the need for labels.
ahh good point, and no, that slipped by me the first time. I'll be sure to keep
this in mind as I go thru and re-code my first attempt with the optimizations I
have in mind for the finished product. Thank you!
--
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: 22 May 2000 00:12:41 -0700
From: Sue Spence <sue@pennine.com>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <8gaml9$qmn@drn.newsguy.com>
In article <8g9oqs$m2e$0@216.155.32.172>, The says...
>
>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'
Jeez, gimme a minute, OK?
>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.
Welcome to usenet! You're lucky - a lot of people don't get any replies at all.
You're swimming in them, and a lot of them are even useful.
>
>I've been here long enough that I don't need any reminders from the regulars to
>look before I perl -e.
>
Hey, you've gotta take the rough with the smooth.
------------------------------
Date: 22 May 2000 07:58:38 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <8gapbe$plj$2@216.155.32.48>
In article <3928C898.116B9DFD@stomp.stomp.tokyo>, "Godzilla!"
<godzilla@stomp.stomp.tokyo> wrote:
| The WebDragon wrote:
|
| > "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
|
| > Just curious, but is there any particular reason
| > your linewrapping is so short?
|
| Yes there is a reason. Is there a reason
| your lines are so long?
dunno about 'so long' as 80 cols is fairly standard, no?
| > What's frustrating is doing a script for
| > someone's benefit....
|
| This is a no-no as a general rule. Anymore I write
| scripts only for close personal friends. Those who
| don't know programming, never realize how much time
| and effort go into writing and rewriting to attain
| a decent script.
I agree for the most part, however I'm also only only a little over three weeks
old as far as perl is concerned (if that).. this is all learning experience for
me, and having some minor useful mini-projects to toss together for the use of
myself, and the other reviewers on the team (all volunteer work.. this isn't a
paying gig to begin with) both lets me learn perl, and makes our collective jobs
easier. The more I learn, and the more I know, the better I'll be able to sell
my services later ;), but THAT, is for later.
| Regex is very difficult to learn and, regex is amongst
| the most useful tools available with Perl. I am both
| enjoying and learning from this thread of 'yours'.
| Much valuable information is being shared with all,
| some of which, I have to sit and study for a period to
| fully understand and appreciate. Your way of discussing
| what is happening and why, is most beneficial.
Indeed, I tend to be a "make certain you are looking at the whole picture"
person in general, and usually like to understand as much as possible PRIOR to
diving into something. This works on many many levels. Anyone who's ever read
any Alan Watts and gotten something out of it can find the concept a useful
'tool' in more ways than just computers.
| Always check under your nose though, sometimes a
| small simple regex might be hiding there, just
| to be ornery.
Hehehe you ain't kidding.
--
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: 22 May 2000 06:41:22 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: REGEXP newbie question
Message-Id: <8gakqi$cdr$1@216.155.32.48>
In article <B54DCC62.B10%john@digitalmx.com>, John Springer
<john@digitalmx.com> wrote:
| > 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";
| }
not to be overly pedantic, but
A-Za-z0-9_.
is incorrect.. it's actually
A-Za-z0-9_
;)
--
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: 22 May 2000 07:09:08 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: SETUID problem (maybe lame)
Message-Id: <8gaiu4$srj$1@orpheus.gellyfish.com>
On Sun, 21 May 2000 17:41:15 +0800 Maciej Mastalarczuk wrote:
> Hi All,
>
> The problem is as follows:
> Non-root user has to perform root-only action. The owner of the script
> is root:root and the mode is:
> -rwsr-x--x (4751). Whenever the user invokes the script he gets the
> message:
>
> Insecure $ENV{PATH} while running setuid at ./test line (something).
>
> How to overcome this? Of course when root invokes the script it works
> fine.
>
You should have read the perlsec manpage before trying to create a setuid script.
Essentially you have to set certain environment variables to known (untainted)
values when running setuid as Perl will go into taint mode automatically.
/J\
--
I have feeling too, you know, like `My stomach hurts', or `I'm going
crazy!'
--
fortune oscar homer
------------------------------
Date: 22 May 2000 04:59:24 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: sorting a list of mixed numbers and text as in perldoc
Message-Id: <8gaerc$1vm$0@216.155.32.48>
In article <Pine.LNX.4.20.0005212035420.18426-100000@hawk.ce.mediaone.net>,
"Andrew N. McGuire " <anmcguire@ce.mediaone.net> wrote:
| On 22 May 2000, The WebDragon wrote:
|
| + In article <slrn8idf1j.tkm.tjla@thislove.dyndns.org>,
| tjla@guvfybir.qlaqaf.bet
| + (Gwyn Judd) wrote:
|
| [ snip ]
|
| + | sort { $b->[1] <=> $a->[1]
|
| [ snip ]
|
| + what if you wanted the output to be:
| +
| + ====
| + dawg? hi low up what's yo 1 2 3
| + ====
| +
| + how would you change that?
|
| Reverse $a and $b in the quoted line above, like so:
|
| sort { $a->[1] <=> $b->[1]
Like this? :
#!/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 { $a->[1] <=> $b->[1]
||
$a->[2] cmp $b->[2]
} map { [$_, m/(\d+)/ ? $1 : $text_first, uc($_)] } @old;
print join " ", @old;
print "\n";
print join " ", @new;
no, I tried that .. this results in
====
1 2 3 dawg? hi low up what's yo
====
when what I wanted was this:
====
dawg? hi low up what's yo 1 2 3
====
--
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: 22 May 2000 06:55:23 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: Suggest an approach for HTML Form submission
Message-Id: <8galkr$cdr$2@216.155.32.48>
In article <392842DE.FA5478FB@home.com>, ecostello@home.com wrote:
| Greetings,
|
| I need to create a Macintosh Perl program that mimics an HTML form
| submission to a web server and parses the resulting page. I have MacPerl
| installed, but I'm not sure I have all the appropriate modules, libraries,
| packages, etc...
|
| Could someone point me in the right direction or suggest an approach?
|
you need CGI.pm (version 2.66 runs perfectly under MacPerl)
download this file: http://stein.cshl.org/WWW/software/CGI/CGI.pm.tar.gz
uncompress into :MacPerl:Download Backups:CGI:
open :CGI.pm-2.66:CGI.pm in BBEdit, and save with Macintosh linefeeds instead of
Unix linefeeds. Do the same for the files contained in the :CGI.pm-2.66:CGI:
subdirectory in there (contains stuff like Carp.pm and Pretty.pm, etc)
open MacPerl:lib: folder, and BACK UP the old CGI.pm and the contents of the
existing :lib:CGI: folder, to MacPerl:Download Backups:CGI Backups:
Copy the new files to the :lib: folder, paying attention to where they belong.
===
there is a folder full of example cgi scripts that you can play with, that comes
with this module, and there are also some live demonstrations and TONS of
documentation at the above website, i.e. http://stein.cshl.org/WWW/software/CGI/
Try this out. You'll go nuts trying to do it any other way. :)
I also recommend you download and install the File::Spec (version 0.7, since 0.8
is still buggy on Mac.. see http://testers.cpan.org/) module as well, and make
sure you use it for any directory/file manipulation that your script does to
ensure port-ability to unix and other places.
HTH
(note sig for reply-to, as my address is spam-blocked)
--
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 04:27:18 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: the use of $_
Message-Id: <B54E2F62.4741%elaine@chaos.wustl.edu>
in article 3928B1B1.FEE549E6@stomp.stomp.tokyo, Godzilla! at
godzilla@stomp.stomp.tokyo quoth:
>> Please name me just one current Operating System that comes with Perl 4.
>
> Someone else listed one of a number of Operating Systems
> still bundled with Perl 4. Sometime around late February
> or early March, a discussion took place on this topic.
> If I remember correctly, at least five or six O/S were
> listed which are bundled with Perl 4, probably still so
> today. There are quite a few servers out there, still
> running Perl 4 right now.
*BSD - Perl 5.005_03+ has been a standard port since its release. OpenBSD
2.7 ships with Perl 5.6.0
Solaris - Perl 5.005_03 since Solaris 8
AIX - Perl 5.005_03 with 4.3.3
Linux - all 5.004 or better since it was released
IRIX - 5.004_04 since 5.6
SCO - doesn't ship with Perl but offers it on website as 5.005_03
Digital UNIX - 5.004_04 since 5.0, 5.005_03 on suppl. CD
Win* - ActiveState is currently at 5.6.0 and 5.005 is with NT Resource kit
MacOS X - will ship with 5.6.0
VMS - Perl 5.004_03 since 6.3 has been on the freeware CD
BeOS - ships with Perl 5.005_03
Sequent DYNIX/ptx - Perl 5.005_03
etc....
I can't think of any that ship with Perl these days that ship with Perl4
except HP-UX...unless some old codger can't handle dealing with Perl 5x and
installs it for the sheer glory of it. A lot of people like Nat Torkington
and others have worked hard to get the vendors on track. Perhaps you are
dealing with some seriously outdated boxes?
> This is reality.
...in an alternate universe permanently set on '1985' :)
e.
------------------------------
Date: Sun, 21 May 2000 21:52:38 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: the use of $_
Message-Id: <3928BD16.3A9AD9A2@stomp.stomp.tokyo>
Elaine Ashton wrote:
> in article 3928B1B1.FEE549E6@stomp.stomp.tokyo, Godzilla! at
> godzilla@stomp.stomp.tokyo quoth:
> >> Please name me just one current Operating System
> >> that comes with Perl 4.
> > Someone else listed one of a number of Operating Systems
> > still bundled with Perl 4. Sometime around late February
> > or early March, a discussion took place on this topic.
> I can't think of any that ship with Perl these days that
> ship with Perl4 except HP-UX...unless some old codger can't
> handle dealing with Perl 5x and installs it for the sheer
> glory of it. A lot of people like Nat Torkington and others
> have worked hard to get the vendors on track. Perhaps you are
> dealing with some seriously outdated boxes?
(snipped)
If you are truly interested in factual
data, there are a few articles on this
somewhere in recent past. Check me on
this as I am uncertain, I think a chap
going by Coke Harrington listed those
O/S still shipping with Perl 4. Be
sure you understand this, I am not
certain on this name. Nonetheless,
there is a list of O/S with Perl 4
bundled, somewhere in archived articles
for this newsgroup.
I checked a few, made a mental note some
O/S still ship with Perl 4 and, my interest
extends no further. This is of no real
concern to me. This is not something of
any real significance.
Godzilla!
------------------------------
Date: Mon, 22 May 2000 05:05:02 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: the use of $_
Message-Id: <B54E383D.4749%elaine@chaos.wustl.edu>
in article 3928BD16.3A9AD9A2@stomp.stomp.tokyo, Godzilla! at
godzilla@stomp.stomp.tokyo quoth:
> I checked a few, made a mental note some
> O/S still ship with Perl 4 and, my interest
Instead of being vague and full of incorrect info, put your money where your
mouth is and offer up some concrete examples. All of the information I
quoted is current and correct unless the vendors and my eyes are deceiving.
e.
------------------------------
Date: 22 May 2000 07:08:23 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: the use of $_
Message-Id: <8gamd7$cdr$4@216.155.32.48>
In article <B54E2F62.4741%elaine@chaos.wustl.edu>, Elaine Ashton
<elaine@chaos.wustl.edu> wrote:
| MacOS X - will ship with 5.6.0
hopefully 5.6.1 ;)
--
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 07:33:59 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: the use of $_
Message-Id: <x7ln13dons.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> my favorite, Perl 4. This aspect, grammar rules, is absolutely
G> impossible under Perl 5 with it lacking a 'human' quality
G> and touch. It is too automated to handle complex programs.
G> It is too 'strict' to handle imaginative programs which
G> require bending, if not breaking some rules. If you wrote
G> some of my programs in Perl 5, they would crash, never run.
G> Perl 5 would gag and die.
hey moron, perl4 is a subset of perl5. your statement make absolutley no
sense as usual. other than a few minor things which are well documented,
most perl4 programs run perfectly fine under perl5. so stop making that
asinine claim. as for you challenges, i have never seen you post any
urls or anything showing what they are. i have no doubt your stuff is a
simplistic as you code and could be duplicated in no time. but you won't
even do that so why bother asking. and the other direction makes more
sense, try writing something with a complex nested data structure in
perl 4. have the appropriate amount of fun.
G> Work on taking this seriously; I don't bluff.
you are as big a bluff as the cliffs of dover.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 22 May 2000 21:31:23 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: the use of $_
Message-Id: <958987864.392966@shelley.paradise.net.nz>
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3928B1B1.FEE549E6@stomp.stomp.tokyo...
> Tintin wrote:
>
> > "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
> > news:39281AD2.8B439E31@stomp.stomp.tokyo...
> > > > Reason 7 is if you're stuck with perl 4. ''I am stuck with perl 4''
> > > > is never *good* reason to do *anything*, except maybe to cut your
> > > > wrists or something.
>
> > > Perl 4 is still currently shipped with some
> > > operating system packages and, Perl 4 concerns
> > > are posted here at times. Perl 4 is still quite
> > > viable and of concern to many. To shun posters
> > > here for use of Perl 4 or to shun those who are
> > > stuck with Perl 4, is most illogical, unrealistic
> > > and perhaps, an act of technological bigotry.
>
> > Please name me just one current Operating System that comes with Perl 4.
>
> Someone else listed one of a number of Operating Systems
> still bundled with Perl 4. Sometime around late February
> or early March, a discussion took place on this topic.
> If I remember correctly, at least five or six O/S were
> listed which are bundled with Perl 4, probably still so
> today. There are quite a few servers out there, still
> running Perl 4 right now.
Whatever they said is incorrect. Look at the facts for yourself.
>
> *shrugs*
>
> This is reality.
Reality for a very small minority.
------------------------------
Date: 22 May 2000 08:43:42 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: Untaint URL character class
Message-Id: <8garvu$1tc$1@newsflash.concordia.ca>
In article <39281145.5C17DF86@stomp.stomp.tokyo>,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>bbfrancis@networld.com wrote:
>
>> I'm trying to untaint URL data for 'a send a link' CGI script, but I'm
>> unsure of all the leagal characters that can be used in a URL.
>
>
>This character set will make for a good
>beginning point for hyperlinks:
>
>(http://[\-~A-Za-z0-9_/\.]+)
This certainly doesn't cover all the legal characters in an URL
(which was the original question). I grant that many URLs will
match this regex but it leaves out even commonly seen chars like
%.
This is an okay regex if you are looking to match URLs, say in
text, and turn them into anchors. Untainting is totally different.
Check out man perlsec, it's interesting. Oh, you'll have to get
Perl 5 for that, by the way.
>Be sure to review basic security issues. You will
>be allowing through a few characters which can be
>combined for trickery. Quite rare with these sets
>but they do exist, ../ is one of concern. Having
>your program watch for a match of certain combinations
>effectively defeats these possible problems.
../ is perfectly safe. If you have information that you
want to keep secret, but can be accessed in this manner,
you've screwed up in more fundamental ways.
>Here is a link with great basic information
>on what you might need to consider. There are
>several pages at this easy-to-read site which
>well covers basic security needs:
>
>http://www.eekim.com/pubs/cgibook/ch09/0902.html
Oh boy, a SAMS book, and from 1997 at that. Handy info on
configuring the NCSA server, used today on less than 0.3% of
websites. And the "secure transactions" part doesn't know
much about SSL, it suggests a custom Java applet to encrypt
communications.
Okay, that's not really fair, the advice wasn't all that bad,
just very outdated. The "new" (as in post 1997) technologies
make some of the concerns moot.
But this is rather far off topic for comp.lang.perl.misc.
Does anyone remember that episode of South Park, where
Kyle and Stan find a man who has been frozen since 1996?
And how this modern world made him do crazy, insane things?
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Mon, 22 May 2000 09:56:13 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: updated : Re: regexes *sigh* damn I hate these things
Message-Id: <3928fc88.4177870@news.skynet.be>
The WebDragon wrote:
>I now need to make sure to extract TWO values from this file (would have been
>nice if he'd said so in the beginning)
>
>Given that the files may contain lines like this:
>
>Name: <a
>href="http://www.planetunreal.com/dl/nc.asp?nalicity/utdm/dm-cyberwar.zip">DM-Cyb
>erwar</a><br>\n
...
I assume that the only actual newlines are marked by "\n", and that the
current line breaks are nothing but word wrap by the NNTP posting...
I snipped the rest of the example because the "Rating" part seems to be
solved. Matching strings like "Name:", "Author:" and "Rating:" can be
used to advance the machine's state.
>or like this:
>
><p>Name: <a href="http://www.planetunreal.com/dl/nc.asp?nalicity/\n
>utdm/dm-nitro.zip">DM-Nitro</a><br>\n
>I need to ALSO extract the 'utdm' portion of the source file from the lines like
>"utdm/dm-cyberwar.zip" and "utdm/dm-nitro.zip"
>
>there MAY or may not be a / or a \n before the 'word' containing the gametype.
>(which may be anything from unrealdm, utdm, utctf, utassault, utother, or
>utdomination)
Tricky. Now we have a possible multiline match. I would think this may
need something like a state machine, which keeps track of where in the
current record we currently are.
>I don't quite understand how to tell the regex that - is a valid 'word'
>character, so that it will find the utother/fire-logo-map.zip as well as
>utdm/DM-Halls_of_redemption.zip
You can't, AFAIK. It's a pity. "locale" seems to be doing it, but you
can't do it as a common user. Currently the best solution (5.6 may
provide features, but I consider it not Ready For The World just yet) is
to use a character class; possibly, for readability, you can put it in a
variable and use that variable in the regex -- don't forget the //o
switch.
$w = "[a-zA-Z0-9_\\-\\.]";
$_ = 'utdm/DM-Halls_of_redemption.zip etc. etc.';
print m!/($w+)!o;
Anyway, here's what I came up with (quickly thrown together, but it
seems to work on the example data):
while(<DATA>) {
if(/Name: +<a +href="http:[^"]+\?nalicity\//gi .. /\G([^"]+)"/g) {
$name = $1 if defined $1;
} elsif(/Rating: +\(1-10\) +([\d\.]+)/) {
$rating = $1;
print "Name = $name, rating = $rating\n";
}
}
__DATA__
(your example data here)
This gives:
Name = utdm/dm-cyberwar.zip, rating = 7.5
Name = utdm/dm-nitro.zip, rating = 9
--
Bart.
------------------------------
Date: 21 May 2000 19:31:27 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Using DBM for simple database?
Message-Id: <8g9a1v$82p$1@orpheus.gellyfish.com>
On Thu, 18 May 2000 18:50:54 -0700 Jeff Zucker wrote:
>
> SQL is not that difficult and does not require anything special to
> serve. You can use it in combination with many kinds of flat files
> using either DBD::CSV or DBD::RAM without anything but Perl and easily
> obtainable/installable Perl modules.
>
Or DBD::XBase indeed ...
/J\
--
We're laughing with her, Marge. There's a big difference. Ha ha
ha! ...with her.
--
fortune oscar homer
------------------------------
Date: Sun, 21 May 2000 22:17:35 +0200
From: Christian Winter <thepoet1@arcormail.de>
Subject: Re: valid email address
Message-Id: <v8g9g8.9c4.ln@usenet-autoren.de>
Jennifer <webmaster@momsathome.on.ca> schrob:
> I'm thinking that if it isn't any_char@any_two_char.any_two_char
> that it isn't valid syntax. I know I have filled out forms and
> forgot the .com. I just want to catch the stupidest of mistakes
> and hopefully narrow down the bad addresses that make it through.
Well, it is nearly as complitcated to check for errors as it is
to check for validity. The points you might have success in checking
are IMHO:
- is the adresses followed by a TLD? (maybe there's a list on internic)
- does it contain at least one "@"?
- does it contain at least one "." after the "@"?
so if you've got an array containing all TLD's:
------------------------------------------------
#!/usr/bin/perl -w
use strict;
my @tld = ("com","net","org","uk","de",.......);
my $addr;
my $valid = 0;
if( $addr =~ /\@\S*\./ && join("", map{ ($addr =~ /$_$/i)?1:0) } @a) > 0) {
$valid = 1;
}
-------------------------------------------------
HTH
Christian
------------------------------
Date: Mon, 22 May 2000 03:49:55 -0400
From: Jennifer <webmaster@momsathome.on.ca>
Subject: Re: valid email address
Message-Id: <3928E6A3.4897649A@momsathome.on.ca>
Neil Kandalgaonkar wrote:
> my $domain = qr/([a-z0-9-]+\.)*[a-z]+/i; # must be fully qualified
OK I just want to understand the regexp. That would allow a
sinlge letter to be valid, right?
Assuming that a valid domain must have at _least_ one
letter|number|dash followed by a dot followed by at least 2
letters (Please correct me if you know that asumption to be
wrong.), would the following work?
if ($domain =~ /([a-z0-9-]+\.)+[a-z]{2,}$/i) {
print "could be valid";
}
else {print "not valid"}
Would it allow the min (assumption described above) and also
third and forth level etc
domains through. Making sure there are no double dots in a row.
I've tried it on several different combinations of domains that I
can think of and it works for all. I only want to _reduce_
invalid, but I don't want to stop _any_ valid.
I'm not concerned about checking against valid TLD's since that
would need to be maintained.
I know the domain part is not perl related, but my real concern
is getting the regexp right. Is there a spec for domain names?
Jennifer
------------------------------
Date: Mon, 22 May 2000 08:24:18 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: valid email address
Message-Id: <S86W4.307$jB2.5921@news.itd.umich.edu>
In article <8g90ru$82q$1@newsflash.concordia.ca>,
Neil Kandalgaonkar <nj_kanda@alcor.concordia.ca> wrote:
>Finaly, the reliably ingenious Abigail has written a module which
>uses Parse::RecDescent to check addresses against RFC 822. Please
>forgive me if this module is not meant to be released, it
>only seems to be available in her personal CPAN directory under
>RFC::RFC822::Address.pm. 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.
I just finished writing an address parser for use in the Perl-based e-mail
client that I'm working on. I also used RFC 822 as my reference, though I
created the parser from scratch because I want to minimize dependence on
non-standard modules. I applied the test suite from Abigail's module to
my code, and after a few tweaks, it passed every test.
The code is below. I'm still working on making it a bit more compact,
but it should be pretty readable as-is.
----------------------------------------------------------------------
use 5.005;
use strict;
while (<>) {
chomp;
if (valid_address($_)) {
print "$_ is a valid address!\n";
} else {
print "$_ is not a valid address!\n";
}
}
sub enum { eval "sub $_[$_] () { $_ } 1" or die for 0 .. $#_; }
my ($lwsp, @tokens, @action);
BEGIN {
enum WHITESPACE => SPECIAL => ATOM => COMMENT => QUOTED => DOMAIN =>;
}
BEGIN {
my $specials = '][()<>@,;:\\".';
$lwsp = '(?:(?:\015\012)?[ \t])+';
@action = (
WHITESPACE, qr/\G($lwsp)/o, \¬hing,
COMMENT, qr/\G\(/, \&parsecomment,
ATOM, qr/\G([^\Q$specials\E\000-\040\177]+)/o, \&pushtoken,
QUOTED, qr/\G("(?:[^"\015\\]+|\\.|$lwsp)*")/so, \&pushtoken,
DOMAIN, qr/\G(\[(?:[^][\015\\]+|\\.|$lwsp)*])/so, \&pushtoken,
SPECIAL, qr/\G([\Q$specials\E])/o, \&pushtoken,
);
}
sub nothing {
;
}
sub pushtoken {
push @tokens, $_[0], pos() - length($1);
}
sub parsecomment {
my $level = 1;
while ($level > 0) {
/\G(?:[^()\015\\]+|\\.|$lwsp)*/sogc
or
/\G\(/gc && $level++
or
/\G\)/gc && $level--
or
die "Error in comment\n";
}
}
sub valid_address {
local $_ = shift;
@tokens = ();
LOOP: while (1) {
last if pos == length;
for (my $i = 0; $i < @action; $i += 3) {
my $begin = pos;
if (/$action[$i+1]/gc) {
eval { $action[$i+2]->($action[$i], $begin) };
return 0 if $@;
next LOOP;
}
}
return 0;
}
my $start = 0;
&is_address($start);
}
sub is_address {
&is_mailbox || &is_group and $_[0] == @tokens;
}
sub is_group {
my $save = $_[0];
return if !&is_phrase;
$_[0] = $save, return if !&is_special($_[0], ':');
if (&is_mailbox) {
while (&is_special($_[0], ',')) {
$_[0] = $save, return if !&is_mailbox;
}
}
$_[0] = $save, return if !&is_special($_[0], ';');
1;
}
sub is_mailbox {
my $save = $_[0];
return 1 if &is_addr_spec;
return if !&is_phrase;
$_[0] = $save, return if !&is_route_addr;
1;
}
sub is_route_addr {
my $save = $_[0];
return if !&is_special($_[0], '<');
&is_route;
$_[0] = $save, return if !&is_addr_spec;
$_[0] = $save, return if !&is_special($_[0], '>');
1;
}
sub is_route {
my $save = $_[0];
return if !&is_special($_[0], '@');
$_[0] = $save, return if !&is_domain;
while (&is_special($_[0], ',')) {
$_[0] = $save, return if !&is_special($_[0], '@');
$_[0] = $save, return if !&is_domain;
}
$_[0] = $save, return if !&is_special($_[0], ':');
1;
}
sub is_addr_spec {
my $save = $_[0];
return if !&is_local_part;
$_[0] = $save, return if !&is_special($_[0], '@');
$_[0] = $save, return if !&is_domain;
1;
}
sub is_word {
return if $_[0] == @tokens;
$tokens[$_[0]] == ATOM || $tokens[$_[0]] == QUOTED ? ($_[0] += 2) : 0;
}
sub is_special {
return if $_[0] == @tokens;
$tokens[$_[0]] == SPECIAL && substr($_, $tokens[$_[0]+1], 1) eq $_[1]
? ($_[0] += 2) : 0;
}
sub is_local_part {
return if !&is_word;
while (1) {
my $save = $_[0];
return 1 if !&is_special($_[0], '.');
$_[0] = $save, return 1 if !&is_word;
}
}
sub is_domain {
return if !&is_sub_domain;
while (1) {
my $save = $_[0];
last if !&is_special($_[0], '.');
$_[0] = $save, last if !&is_sub_domain;
}
1;
}
sub is_sub_domain {
return if $_[0] == @tokens;
$tokens[$_[0]] == DOMAIN || $tokens[$_[0]] == ATOM ? ($_[0] += 2) : 0;
}
sub is_phrase {
return if !&is_word;
1 while &is_word;
1;
}
----------------------------------------------------------------------
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: 22 May 2000 00:07:08 -0700
From: Sue Spence <sue@pennine.com>
Subject: Re: What's this line which Perl added to AUTOEXEC.BAT?
Message-Id: <8gamas$q6o@drn.newsguy.com>
In article <1071a7a9.2bf1ce74@usw-ex0105-034.remarq.com>, bjanko says...
>
>Thanks for believing me. That's exactly what happened: Windows
>could not find "win.com" thanks to ActivePerl. Some people
>doubt this. Oh, well.
>
Would you please show us what your PATH assignments were both before and after
installation of AS Perl? You seem to be a special case in that you are the
only person I'm aware of for whom there was a problem of this sort in installing
AS Perl. If you still want to talk about it, we might as well get some
information that might be of some use to the developers.
------------------------------
Date: Mon, 22 May 2000 09:53:54 GMT
From: newsmay2000@ordinate.co.uk (Ben Hambidge)
Subject: Win32::OLE question: translating from VB/VFP
Message-Id: <3928548e.5142003@news.freeserve.net>
I wonder if someone can help me...
I've got an OLE Automation application that I need to query in Perl.
I've installed it properly, and the following test samples work
correctly in Visual Basic and Visual FoxPro respectively. However, my
translation of the code into Perl results in errors. What do I need to
alter to have this code translated properly?
The errors that I get are several data mismatch errors and "function
argument value type or count is invalid" errors, then a few "variable
not found" (internal variables to the application) and then Perl
process crashes.
Any help would be greatly appreciated!
Ben
Visual Basic:
Private Declare Sub qzole Lib "c:\qzole\qzole.dll" ()
Sub prem()
Dim oprem As Object
Set oprem = CreateObject("qzole.classqzole")
oprem.calcphi "LICC", "M", 33, "", False, False, "A", "", 0, "", 0,
"", False, False, "", 0, 0, 2000, "M", 1, 65, 1, False, False, 100,
200, "A115827N"
MsgBox (oprem.premium)
End Sub
==================================================
Visual FoxPro:
SET DEFAULT TO c:\qzole
oPrem = CREATEOBJECT("qzole.classqzole")
oPrem.calcphi('LICC', 'M', 33, {}, .F., .F., 'A', '', 0, ;
'', 0, {}, .F., .F., '', 0, 0, 2000, 'M', 1, 65, 1, .F.;
.F., 100, 200, 'A115827N')
? oPrem.premium
==================================================
My Perl Code:
use strict;
use Win32::OLE;
my $oPrem = Win32::OLE->new('qzole.classqzole');
$oPrem->calcphi("LICC","M",33,0,0,0,"A","",0,
"",0,0,0,0,"",0,0,2000,"M",1,65,1,0,0,
100,200,"A115827N");
print $oPrem->premium;
print "\n";
------------------------------
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 3118
**************************************