[16531] in Perl-Users-Digest
Perl-Users Digest, Issue: 3943 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 7 21:10:25 2000
Date: Mon, 7 Aug 2000 18:10:15 -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: <965697015-v9-i3943@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 7 Aug 2000 Volume: 9 Number: 3943
Today's topics:
Re: reg expressions - protect html <elijah@workspot.net>
Re: reg expressions - protect html <lr@hpl.hp.com>
Re: reg expressions - protect html <godzilla@stomp.stomp.tokyo>
Re: reg expressions - protect html <godzilla@stomp.stomp.tokyo>
Re: reg expressions - protect html <godzilla@stomp.stomp.tokyo>
Re: Regular Expressions & Substitution <fordt@uci.edu>
returning error message (daemon)
script for getting modem to make internet connection. <brentmi@bigpond.com>
Simple regular Expression Question <kennylim@techie.com>
Re: Simple regular Expression Question <rickysregistration@hotmail.com>
Re: Simple regular Expression Question <tim@ipac.caltech.edu>
Re: When does it pay to presize an array? (Andrew J. Perrin)
win32 netadmin <gorgano@altavista.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Aug 2000 22:09:57 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: reg expressions - protect html
Message-Id: <eli$0008071659@qz.little-neck.ny.us>
In comp.lang.perl.misc, Larry Rosler <lr@hpl.hp.com> wrote:
> Godzilla! <godzilla@stomp.stomp.tokyo> says...
> > ... I would not use warnings nor strict.
> > Both slow your program down and bloat memory usage.
>
> Please provide some evidence to support this assertion. Unlike
> religion, in computing as in other branches of engineering or science
> assertions of this type must be verifiable.
I love using the Benchmark module!
With Perl5.6.0:
Benchmark: timing 1000000 iterations ...
WarnStrict: 19 wallclock secs (17.52 usr + 0.36 sys = 17.88 CPU)
WarnNoStrict: 18 wallclock secs (16.95 usr + 0.38 sys = 17.33 CPU)
NoWarnStrict: 19 wallclock secs (18.11 usr + 0.44 sys = 18.55 CPU)
NoWarnNoStrict: 17 wallclock secs (17.00 usr + 0.41 sys = 17.41 CPU)
(All the @num/s stuff deleted.)
Here's the code:
#!/usr/bin/perl # for NoWarn
#!/usr/bin/perl -w # for Warn
#use strict; # for NoStrict
use strict; # for Strict
use Benchmark;
use vars qw( $a $b );
timethese(10_000_000, {
NoWarnStrict => q!
$a = 1;
$b = 10;
$a += $b;
!,
});
Different code in the function might yeild more intesting
results. Try it and post.
Elijah
------
saves his benchmark scripts so as to be able to redo them with new Perls
------------------------------
Date: Mon, 7 Aug 2000 15:33:19 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: reg expressions - protect html
Message-Id: <MPG.13f8d907671797da98ac43@nntp.hpl.hp.com>
In article <398F2EE9.4D805073@stomp.stomp.tokyo> on Mon, 07 Aug 2000
14:49:29 -0700, Godzilla! <godzilla@stomp.stomp.tokyo> says...
> Larry Rosler wrote:
>
> > Godzilla! entices Mr. Rosler:
>
> > > ... I would not use warnings nor strict.
> > > Both slow your program down and bloat memory usage.
>
> > Please provide some evidence to support this assertion.
> > Unlike religion, in computing as in other branches of
> > engineering or science assertions of this type must be
> > verifiable.
>
> Yes. I have a Bachelor's in Science. Independent
> verification is one of many building blocks of
> good practices in Scientific Method.
Yes, but reference to 'authority' is not. 'Ipse dixit' doesn't cut it.
> Consult with Joseph Hall and Randall Schwartz. Both
> have greater expertise in Perl and clearly a better
> ability to explain technical details on this. You
> will also find references to this in Joseph Hall's
>
> _Effective Perl Programming_
>
> along with other references to problems in using
> pragma hints I have not mentioned, thus far. Rest
> assured, at an appropriate strategic moment, I will
> let fly these other jewels of intellectual rockets.
I can hardly wait.
For the benefit of those who may have limited access to deadtreeware,
here is EPP on the subject (p. 144);
Run-time warnings impose a small speed penalty on programs.
In addition, it is not a good idea to present unexpected or
spurious warning messages to users. This, in general, -w
warnings should be used only during development. Warnings
should be *turned off* for code that is released to the
world, much as assert() tests shouldn't be compiled into
final versions of C programs.
The *use strict* pragma is lightweight and can be left in
released code with no ill effects.
Now, let's go back to your assertion, which you claim is based on this
book.
> > > ... I would not use warnings nor strict.
> > > Both slow your program down and bloat memory usage.
Not a word in the 'authority' about memory usage, and a clean report for
'use strict;'. The 'small speed penalty' for '-w' isn't quantified.
I'd have to do benchmarks before making such a statement.
> Logical thinking might suffice in lieu of independent
> verification on these notions.
But logical thinking ('theoretical science') cannot lead to verifiable
results except via 'experimental science'. (I'll match my PhD in
Experimental Nuclear Physics against your BS, any time.)
To add some substance to this discussion, regarding EPP's other point:
The question of '-w' in production code has been discussed here, with
diverse views.
To me, dropping '-w' is like taking off the seat belt when driving out
of the parking lot. My code runs under normal conditions without
generating warnings. So a warning represents some sort of unexpected
condition, which I would like to know about. I can handle that in
production code by providing my own $SIG{__WARN__} handler, which mails
me the error message and stack trace, etc., and does the appropriate
thing for the user.
The only serious concern I might harbor has to do with later releases of
perl introducing new warnings into operating production code. I would
still like to know about such things, though others might not. I think
the rate of such changes is diminishing.
> Praise the Lord. Pass the bread and wine, please.
>
> Godzilla!
>
> --
> With my Lord's Grace, I will rock you.
> http://la.znet.com/~callgirl3/spirit.mid
Hallelujah! We are saved!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 07 Aug 2000 15:41:33 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: reg expressions - protect html
Message-Id: <398F3B1D.6D4523C8@stomp.stomp.tokyo>
Eli the Bearded wrote:
> Larry Rosler wrote:
> > Godzilla! excitely blurts:
> > > ... I would not use warnings nor strict.
> > > Both slow your program down and bloat memory usage.
> > Please provide some evidence to support this assertion. Unlike
> > religion, in computing as in other branches of engineering or science
> > assertions of this type must be verifiable.
> I love using the Benchmark module!
> With Perl5.6.0:
> Benchmark: timing 1000000 iterations ...
> WarnStrict: 19 wallclock secs (17.52 usr + 0.36 sys = 17.88 CPU)
> WarnNoStrict: 18 wallclock secs (16.95 usr + 0.38 sys = 17.33 CPU)
> NoWarnStrict: 19 wallclock secs (18.11 usr + 0.44 sys = 18.55 CPU)
> NoWarnNoStrict: 17 wallclock secs (17.00 usr + 0.41 sys = 17.41 CPU)
(snippage)
> Different code in the function might yeild more intesting
> results. Try it and post.
Mr. Rosler is not going to be very happy with you. =)
Clearly, results yielded would be directly proportionate
to a script's length. However, you have touched upon a most
interesting notion. I would not be surprised to discover
certain types of coding, certain syntax, would yield very
interesting results on pragma hints versus no pragma hints.
This is highly logical thinking on your part, Eli the Bearded.
Excellent point Bearded One. I have a beard as well but I
am certain there are those here who would be offended should
I display my well cropped beard, at least well cropped during
hot Summer months.
Heh!
Godzilla!
--
I have legs but a big butt but will rock you anyhow.
http://la.znet.com/~callgirl3/legs.mid
------------------------------
Date: Mon, 07 Aug 2000 15:52:18 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: reg expressions - protect html
Message-Id: <398F3DA2.E1230DF1@stomp.stomp.tokyo>
Larry Rosler wrote:
> Godzilla! giggles:
> > Larry Rosler wrote:
> > > Godzilla! entices Mr. Rosler:
(snippage)
> I'd have to do benchmarks before making such a statement.
I concur. Seems a good idea to me.
Godzilla!
--
On my carpet, I will rock you.
http://la.znet.com/~callgirl5/carpet.mid
------------------------------
Date: Mon, 07 Aug 2000 16:17:10 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: reg expressions - protect html
Message-Id: <398F4376.698443A6@stomp.stomp.tokyo>
Larry Rosler wrote:
> > Godzilla! giggles even more:
> > Larry Rosler wrote:
> > > Godzilla! entices Mr. Rosler:
(snippage)
> (I'll match my PhD in Experimental Nuclear Physics against your BS,
> any time.)
I'll match common sense against both my B.Sc. in Earth Science
and my Ph.D. in English, any ol' day. Not so sure I would hedge
a bet on common sense versus my Ph.D. in Street Smarts earned
by attending the University Of East Los Angeles Streets as a
young prodégée teenager and young adult.
Godzilla!
--
In A Garden Of Eden, I will rock you.
http://la.znet.com/~callgirl3/inagadda.mid
------------------------------
Date: Mon, 7 Aug 2000 16:54:23 -0700
From: "Tom Ford" <fordt@uci.edu>
Subject: Re: Regular Expressions & Substitution
Message-Id: <8mni3b$f8j$1@news.service.uci.edu>
> Note: $Order[3][0] will contain the value of $Operand at the time it was
> assigned, not at the time it is used. Is that what you want?
Yep. I just find it easier to read when I assign the regular expression
string to a variable, plus I use the same string in multiple regex's so when
I have it assigned to $Operand, it just makes it easier to edit all of them
in one step.
> Ah, another C programmer joins our ranks.
Hehe, not really. Although I do know C fairly well, I never really used it
much (never really liked it that much). I've been working in Basic(DOS
based, not VB) and Assembly (x86, mostly DOS) the past few years, cause I
really enjoy those languages. Now I've discovered Perl and found I enjoy it
too, and hope to learn it as well as Basic and asm. Actually, to tell you
the truth, what I'm trying to make is a Basic to Assembly translator in Perl
:) What better way to expand my knowledge of three languages at once? hehe
> Those aren't really escape chars, they're backreferences. Also (IIRC)
> that format is deprecated. Use $1, $2, etc. instead.
Can you use those in the actual regular expression? I thought within the
regex you used the \1, \2 version, and afterwords the $1, $2, or does that
only apply to the LHS?
> Yes, because the RHS of a regex is normally taken literally. Change your
> 's///' to 's///ee' -- the /ee will force (double) evaluation of the RHS
> as an expression.
Ahh, thank you. I was hoping there was something of this sort. I'm learning
so much. Thanks again.
-Tom
------------------------------
Date: Mon, 07 Aug 2000 23:46:07 GMT
From: daemon@i.am.daemon (daemon)
Subject: returning error message
Message-Id: <slrn8ouii0.1lu.daemon@snowcrash.0x68656c6c.net>
This is probably an FAQ question, but I couldn't find an answer in
the FAQ or 'man perlvar'.
I'm writting a module and need to be able to return an error string
in the event of a problem. I can't just set $! because perl
expects that to be a numeric value. So far the best I could come
up with is to use a global variable $errmsg and set that when
needed. For example:
unless (open (FILE, $file)) {
$errmsg = "can't open $file";
return;
}
Is there a better way to go about this?
--
Citizens, elect Satan in 2000!
------------------------------
Date: Tue, 8 Aug 2000 09:49:46 +1000
From: Brent <brentmi@bigpond.com>
Subject: script for getting modem to make internet connection.
Message-Id: <MPG.13f9f621a1af8185989688@news.bigpond.com>
Hi there I was wondering if anyone new if there was something in perl
that could be used to talk to a modem and dial an internet connection.
Is there a module or something I can call to start with?
The result I'm looking for is something that can dial multiple POPs one
after the other and once a connection is made I want to do some other
stuff to check links, mail, ping times etc, log the events then
disconnect and do the next.
Would anyone no of something allready in existance or a good starting
point?
Its all a bit of a learning experience for me as I'm not a perl guru...
but trying to learn :)
Thanks
Brent.
------------------------------
Date: Mon, 07 Aug 2000 23:15:04 GMT
From: "Kenny Lim" <kennylim@techie.com>
Subject: Simple regular Expression Question
Message-Id: <YpHj5.26736$0W4.628139@newsread2.prod.itd.earthlink.net>
Hi All,
I would like to know if it's possible that to increment
on a "specific number" on a given project name.
Example.
ETThread226
Major Version = 2 (ie. increment to 3)
or
Minor Version = 26 (ie. increment to 27)
Results :
To have either
ETThread326
or
ETThread 227
What I am trying to achieve is to provide the flexibily to upgrade the
version based on the release type. (major or minor release)
Any advise would be great. Thanks in advance.
Kenny-
------------------------------
Date: Tue, 08 Aug 2000 00:44:16 GMT
From: "Earthlink News" <rickysregistration@hotmail.com>
Subject: Re: Simple regular Expression Question
Message-Id: <AJIj5.27161$Z6.737454@newsread1.prod.itd.earthlink.net>
Kenny Lim <kennylim@techie.com> wrote in message
news:YpHj5.26736$0W4.628139@newsread2.prod.itd.earthlink.net...
> Hi All,
>
> I would like to know if it's possible that to increment
> on a "specific number" on a given project name.
>
> Example.
>
> ETThread226
>
> Major Version = 2 (ie. increment to 3)
>
> or
>
> Minor Version = 26 (ie. increment to 27)
>
Hi Kenny,
Well, if you assume that the naming convention is a bunch of letters
followed by the #'s, then you could try:
$file = "ETThread226";
$file =~ m%\D+(\d)(\d*)$%;
$major = $1;
$minor = $2;
Or, if the name of the file can also contain numbers:
$file = "ET3Thr43ead226";
$file =~ m%(\d)(\d*?)$%;
$major = $1;
$minor = $2;
Hope that helps,
Rick.
------------------------------
Date: Mon, 07 Aug 2000 17:49:44 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Simple regular Expression Question
Message-Id: <398F5928.1D826908@ipac.caltech.edu>
man perlop. Look for stuff about the s/// switch 'e'. E.g.
$a="foo233";
$maj=0;
$a =~ s/(^.*foo)(\d)(\d\d)/$1.($maj?($2+1).$3:$2.($3+1))/e;
print $a
When $maj == 0:
foo234
When $maj == 1:
foo333
--
-- Tim Conrow tim@ipac.caltech.edu 626-395-8435
------------------------------
Date: 07 Aug 2000 20:50:53 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: When does it pay to presize an array?
Message-Id: <u4s4wwp76.fsf@demog.berkeley.edu>
nospam@hairball.cup.hp.com (Richard J. Rauenzahn) writes:
[snip]...
>
> So, I made the following changes and got *significantly* better results:
> $#array = $size - 1;
> $#array = -1; # change 1: This 'resets' the array,
> # but doesn't deallocate the memory.
^^^^^^^^^
Is this documented? I couldn't find it on an admittedly cursory glance.
> foreach (0..$#array) {
Well, yes, this is faster, but it's not doing the same thing, since $#
is now -1. When I changed it to
foreach (0..$size) {
which is comparable to the bypush() routine, I got the following,
perhaps even more puzzling, results. The first ones are from perl
5.005_03 on a Win32 system (P150, 96MB RAM), while the second are from
5.6.0 on Linux (debian, P90, 16MB RAM, on a laptop). Note the very
strange differences in scale, particularly that the only time it
helped *at all* to presize was on the *smallest* of the three arrays,
and that looks like it could be a spurious result.
Not at all what I would have expected (nor, frankly, very useful,
since creating a 1000-element array is a fairly trivial operation to
begin with). I'd still love to hear from any of the perl internals
gurus about when (if ever) it makes sense to presize an array that
will become very large.
Results from slovo (This is perl, version 5.005_03 built for
MSWin32-x86-object):
aperrin@SLOVO ~/perl % perl rauenzahn.pl
1000 Trials:
Benchmark: timing 1000 iterations of Presized, Pushed...
Presized: 10 wallclock secs (10.48 usr + 0.00 sys = 10.48 CPU)
Pushed: 11 wallclock secs (10.57 usr + 0.00 sys = 10.57 CPU)
---*---
10000 Trials:
Benchmark: timing 1000 iterations of Presized, Pushed...
Presized: 105 wallclock secs (104.56 usr + 0.00 sys = 104.56 CPU)
Pushed: 98 wallclock secs (96.81 usr + 0.00 sys = 96.81 CPU)
---*---
100000 Trials:
Benchmark: timing 1000 iterations of Presized, Pushed...
Presized: 1048 wallclock secs (1047.00 usr + 0.04 sys = 1047.04 CPU)
Pushed: 988 wallclock secs (988.15 usr + 0.03 sys = 988.18 CPU)
---*---
aperrin@SLOVO ~/perl %
Results from achebe (This is perl, v5.6.0 built for i586-linux)
achebe:~/nthome/perl> perl rauenzahn.pl
1000 Trials:
Benchmark: timing 1000 iterations of Presized, Pushed...
Presized: 17 wallclock secs (16.67 usr + 0.00 sys = 16.67 CPU) @ 59.99/s (n=1000)
Pushed: 14 wallclock secs (14.22 usr + 0.01 sys = 14.23 CPU) @ 70.27/s (n=1000)
---*---
10000 Trials:
Benchmark: timing 1000 iterations of Presized, Pushed...
Presized: 170 wallclock secs (169.47 usr + 0.01 sys = 169.48 CPU) @ 5.90/s (n=1000)
Pushed: 143 wallclock secs (143.12 usr + 0.00 sys = 143.12 CPU) @ 6.99/s (n=1000)
---*---
100000 Trials:
Benchmark: timing 1000 iterations of Presized, Pushed...
Presized: 1624 wallclock secs (1624.05 usr + 0.09 sys = 1624.14 CPU) @ 0.62/s (n=1000)
Pushed: 1435 wallclock secs (1434.34 usr + 0.03 sys = 1434.37 CPU) @ 0.70/s (n=1000)
---*---
--
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------
------------------------------
Date: Mon, 07 Aug 2000 22:02:19 GMT
From: Jason Hurst <gorgano@altavista.com>
Subject: win32 netadmin
Message-Id: <8mnbl9$ogd$1@nnrp1.deja.com>
I’m trying to validate a user with perl through our domain. I found
the netadmin package and tried using the UserGetAttributes function.
This works and returns some of the information, but it returns a blank
field for password; which I kind of need to validate a user. So my
question is, has anyone else seen this, or am I doing something wrong?
Here is the code I’m using, this is just kind of test stuff I’m using
to see if I can get it working (it’s pretty much strait out of the man
page):
use Win32::NetAdmin qw(GetAnyDomainController GetUsers GroupIsMember
UserGetAttributes UserSetAttributes);
my %hash;
GetUsers("", FILTER_NORMAL_ACCOUNT , \%hash)
or die "GetUsers() failed: $^E";
foreach (keys %hash) {
my ($password, $passwordAge, $privilege,
$homeDir, $comment, $flags, $scriptPath);
print "$_ ($hash{$_})\n";
UserGetAttributes("", $_, $password, $passwordAge,
$privilege,
$homeDir, $comment, $flags, $scriptPath)
or die "UserGetAttributes() failed: $^E";
print "$password,$passwordAge,$privilege,$homeDir,$comment,$flags,$scrip
tPath\n\n";
}
thanks for the help.
-jason
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 3943
**************************************