[9635] in Perl-Users-Digest
Perl-Users Digest, Issue: 3229 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 22 23:07:29 1998
Date: Wed, 22 Jul 98 20:00:18 -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 Wed, 22 Jul 1998 Volume: 8 Number: 3229
Today's topics:
Re: 100% FREE Franchise Site (Martien Verbruggen)
Re: comparing files in perl (Martien Verbruggen)
DBD ODBC on unix <ralphcook@erols.com>
Re: has anyone attempted a script that can replicate it (Martien Verbruggen)
Re: HELP locking files (Martien Verbruggen)
Re: How to know the number of hash items without runnin (Josh Kortbein)
Re: How to know the number of hash items without runnin (Martien Verbruggen)
Is There a Newsgroup for completed scripts? (Rick Roby)
Re: Module scope (Mark-Jason Dominus)
no Net::IMAP ?? jbnivoit@ix.netcom.com
Re: novice Q; reading columns of numbers (nobody)
OT? Fly GIF's <jesse@savalas.com>
Re: Perl -pi (Martien Verbruggen)
Re: Perl array name (Ronald J Kimball)
Re: Perl CGI's under Windows NT (nobody)
Re: Perl with SSI (mikep)
Re: specific character/position in string (Larry Rosler)
Re: specific character/position in string <rick.delaney@shaw.wave.ca>
Re: specific character/position in string (Larry Rosler)
Re: temp directory for both unix and windows platform (Martien Verbruggen)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Jul 1998 02:39:47 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: 100% FREE Franchise Site
Message-Id: <6p67pj$3ab$2@nswpull.telstra.net>
In article <190798221712@anywhereusa.com>,
"Javier Fernandez" <Sierra@AnywhereUSA.com> writes:
> 100% FREE Franchise Site at URL http://www.sierranv.net/~online
Thank you. I was afraid for a minute that you would charge me for this
spam.
> This Site contain more than 2500 absolutely FREE business documents
> (business reports, ideas, examples of agreements, US law, job proposals
> of work from your home and much more). All of them will help you to
Just what I was waiting for! US law documents. That will be useful. I
can just imagine sitting at my desk, next week or so, and suddenly
feel an incredible craving to read a US law document. I'll probably
also email it to everyone I know in Europe.
> This Site also will create for you friendly environment with entertainment
> and fun. A Worldwide Competition, Art Gallery, Amateur & Professional
> Video of Pretty Girls and Ladies from CIS, European countries & Worldwide
I was waiting for this part of the spam. Enetertainment, fun, and
girls. Why do spammers keep disappointing me this way?
> waiting for your attantion in your spare time. Looking on ones you will
> refresh your viewpoint and will revision life goals. May be your life will
> crowd new penpals and friends or business partmer or ... somebody more
> significant.
attantion? partmer? What are you trying to say here anyway?
> Visiting our Site you will save your time and money !!! All of our services
> today, as a rool, cost money in Internet but they are FREE OF CHARGE on our
> Site.
Huh? As a 'rool' all your services cost money on the Internet, but
they are free on your site? Where is your site? Not part ot the
Internet?
> The project will be constant development AND CONSTANT WILL BE FREE !!!
yeah, yeah.
> Javier Fernandez, President of Sierra Business Corporation,
> Stuff and Representatives of Corporation
Oooh, the prez himself. The president of Stuff. Cool.
Please, go away.
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm desperately trying to figure out
Commercial Dynamics Pty. Ltd. | why kamikaze pilots wore helmets - Dave
NSW, Australia | Edison
------------------------------
Date: 23 Jul 1998 02:32:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: comparing files in perl
Message-Id: <6p67cp$3ab$1@nswpull.telstra.net>
In article <6p5n18$ei4@jupiter.planet.net>,
impactid@pantheon.yale.edu () writes:
> i'm wondering if there's a perl function or module that would
> do what diff does in unix shell.
This question was asked a few weeks back, on this very newsgroup.
> please post or email cwu@geocities.com
Please use www.dejanews.com to find that thread.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Can't say that it is, 'cause it ain't.
NSW, Australia |
------------------------------
Date: Wed, 22 Jul 1998 22:29:27 -0400
From: Ralph Cook <ralphcook@erols.com>
Subject: DBD ODBC on unix
Message-Id: <35B6A007.1A1672BD@erols.com>
I have a small problem,
When I compile/install the ODBC DBD module on a unix box using shared
libraries and run a test app I get an error saying it cannot find
symbols that I know are in my ODBC drivers .so file. If I conpile and
install it using static link libraries , It works fine.
My LD_LIBRARY_PATH(S) is good (I can run other my other C code using the
odbc.so files).
How do I get perl 5.04 to look and find my shared odbc.so file? Is there
something in the dynaload module?
Thanks for any help.
------------------------------
Date: 23 Jul 1998 02:43:27 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: has anyone attempted a script that can replicate itself and then run the copy?
Message-Id: <6p680f$3ab$4@nswpull.telstra.net>
In article <6p5p5u$qes$1@nnrp1.dejanews.com>,
jhestyr@my-dejanews.com writes:
> text
By lack of meaningful content, We'll just use the subject:
Subject: has anyone attempted a script that can replicate itself
and then run the copy?
yes.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd. | crops where there ain't no crops.
NSW, Australia |
------------------------------
Date: 23 Jul 1998 02:47:03 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: HELP locking files
Message-Id: <6p6877$3ab$5@nswpull.telstra.net>
In article <35B67078.9F540CDD@nette.com>,
Michael <michael@nette.com> writes:
> I am trying to write to a file in Win32 as a response to submission via
> a form. It should modify an HTML page, but I am getting inconsistent
> results (the file is empty or missing parts). Is this because I am not
possible. If there is more than one access to the file at once. Maybe
you're screwing it up by reading and writing from the same script, and
not doing it correctly.
You don't show code, we cannot help.
> locking it? and if so, then how do I lock it. I tried using flock but
> that didn't work.
Maybe you didn't try the right way.
Suggested reading:
# perldoc -f flock
http://www.stonehenge.com/merlyn/WebTechniques/col04.html
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd. | inexactitude.
NSW, Australia |
------------------------------
Date: 23 Jul 1998 01:52:15 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: How to know the number of hash items without running loop.
Message-Id: <6p650f$aj5$1@news.iastate.edu>
yroh (yroh@samsung.co.kr) wrote:
: Without running loop, is there way to count how many items the hash has?
$count = scalar(keys(%hash));
Josh
--
__________________________________________
She had heard all about excluded middles;
they were bad shit, to be avoided.
- Thomas Pynchon
------------------------------
Date: 23 Jul 1998 02:54:08 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to know the number of hash items without running loop.
Message-Id: <6p68kg$3ab$6@nswpull.telstra.net>
In article <6p5roe$o9s$1@news-read.att.co.kr>,
yroh <yroh@samsung.co.kr> writes:
> Without running loop, is there way to count how many items the hash has?
# perldoc perlfaq4
[snip]
How can I know how many entries are in a hash?
[snip]
Please, please, please, USE the documentation that comes with perl
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: Thu, 23 Jul 1998 01:00:45 GMT
From: richie@Rednecks.com.nospam.ok (Rick Roby)
Subject: Is There a Newsgroup for completed scripts?
Message-Id: <35b68aae.41336938@enews.newsguy.com>
I am looking for a newsgroup that posts perl and cgi scripts......
Reply or forward to: Richie@rednecks.com. thanks!
------------------------------
Date: 22 Jul 1998 21:13:47 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Module scope
Message-Id: <6p62ob$jr9$1@monet.op.net>
In article <6p3gf2$tii$1@nnrp1.dejanews.com>, <livshits@netscape.com> wrote:
>is there replace the local scope (Foo::) by main:: so that I can just
>say proc and it will look at main::proc and not Foo::proc.
In package Foo, write:
*proc = \&main::proc;
Then it will behave the way you want it to.
Greg suggested the Exporter, but I don't think it is likely to be
helpful in this particular case.
Also, don't say `scope'; say `package'. Scope is something different.
------------------------------
Date: Mon, 20 Jul 1998 07:00:03 -0700
From: jbnivoit@ix.netcom.com
Subject: no Net::IMAP ??
Message-Id: <35B34D63.DB1@ix.netcom.com>
Hi everybody,
i'm a little surprised that the libnet bundle does not come with
a Net::IMAP package (it has Net::POP3). Do i have an older version? Is
anyone
working on such a thing?
jb
PS: CC'ing me directly on the reply would be appreciated. thx.
------------------------------
Date: 23 Jul 1998 01:21:45 GMT
From: ac1@fspc.netsys.itg.telecom.com.au (nobody)
Subject: Re: novice Q; reading columns of numbers
Message-Id: <6p6379$2p1@newsserver.trl.OZ.AU>
isifuelo@my-dejanews.com wrote:
: I'm trying to read html file which contains 6 columns seperated by spaces
: [deleted html stuff]
: A B C D E F
: 1/05/98 25.545 25.875 26.225 25.323 2,790,245
: 1/02/98 25.000 25.375 25.750 25.063 2,566,445
: 12/31/97 25.225 24.938 25.545 24.625 3,242,645
: ^--------------------------------^ move here
: I'd like to reformat above so numbers are seperated using commas,
: commas removed from numbers (1,234,567 -> 1234567), column B moves
: after E, and dates reveresed (line with old date at the beginning of file).
: output should look like:
: 12/31/97......
: 1/02/98,25.875,26.225,26.225,25.000,2790245
: 1/05/98,...
Err, I think those numbers belong to the last record, not the second.
: I'm trying to match...
: (\d(\d)?)/(\d(\d)?)/(\d\(d)?)\s([0-9]+(\.[0-9]*)?)\s([0-9]+(\.[0-9]*)?)\s([0-
: 9]+(\.[0-9]*)?)\s([0-9]+(\.[0-9]*)?)\s([0-9]*) i dont know how to do last
: column (number with commas) is that right? what other stuff i need to make it
: a perl program (using perl on win95).
That's the second ugliest regex I've ever seen :-). I can't imagine the pain
it's probably causing the regex compiler under WinDoze.
BeginDitty (first cut, suggestions welcome).
#!/opt/perl5/bin/perl -w
$Idx = 0;
while (<>) {
s/,//g;
@Fld = split;
$Str[$Idx++] = "$Fld[0],$Fld[2],$Fld[3],$Fld[4],$Fld[1],$Fld[5]";
}
while (--$Idx ge 0) {
print "$Str[$Idx]\n";
}
EndDitty
Regards,
AC.
------------------------------
Date: Wed, 22 Jul 1998 18:00:34 -0700
From: Jesse Rosenberger <jesse@savalas.com>
Subject: OT? Fly GIF's
Message-Id: <35B68B31.DCAEE882@savalas.com>
Well this is probably a little off-topic, I know, but I couldn't find a
newsgroup, or a decent mail-group that could help me. I am in the
process of writing a Perl script that will use 'Fly' to take text from a
form (I already know how to do that part), and place it on an image at a
certain spot, at a certain size, and in a certain color. Ex. I have a
background image with some graphics already, and I have an html form
with a single line input that will post to a cgi script that will output
the text from the form in purple at size 60 font, and have it located at
x=150 pixels, y=300 pixels on the image. How can I do it? If you don't
know...can you please refer me to another newsgroup, or someone that
would know?
Thanks in advance,
Jesse Rosenberger
------------------------------
Date: 23 Jul 1998 02:42:11 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl -pi
Message-Id: <6p67u3$3ab$3@nswpull.telstra.net>
In article <35B666C7.D13B9224@netscape.com>,
BJ Kim <benk@netscape.com> writes:
> I'm trying to edit in place a certain file using this command
>
> perl -p -i.bak -e "s/pear/plum/" fruit.txt
>
> I get this error:
> Can't do inplace edit: fruit.txt is not a regular file.
So... What sort of file is fruit.txt? What is the platform? Where is
the directory listing that shows us what fruit.txt is? You'll need to
provide more information.
Before posting again, though, please read the perldiag documentation:
# perldoc perldiag:
[snip]
Can't do inplace edit: %s is not a regular file
(S) You tried to use the -i switch on a special file,
such as a file in /dev, or a FIFO. The file was
ignored.
[snip]
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: Wed, 22 Jul 1998 22:33:07 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl array name
Message-Id: <1dclalq.kmv60q1p1664gN@bay1-119.quincy.ziplink.net>
[disregard earlier post, which has been canceled]
Larry Rosler <lr@hpl.hp.com> wrote:
> That is certainly a simple and usable approach, but might get you into
> trouble in various ways. For example, suppose the name is not a valid
> Perl identifier?
Symbolic references may get you into trouble, but not in the way you
gave as an example. Any string is a valid identifier in a symbolic
reference.
DB<1> $x = "is this\tan\ninvalid identifier???"
DB<2> $$x = "no, it works!"
DB<3> x $$x
0 'no, it works!'
DB<5> X ~is
$is this^Ian^Minvalid identifier??? = 'no, it works!'
DB<6>
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 23 Jul 1998 01:26:03 GMT
From: ac1@fspc.netsys.itg.telecom.com.au (nobody)
Subject: Re: Perl CGI's under Windows NT
Message-Id: <6p63fb$2p1@newsserver.trl.OZ.AU>
Download Xitami (or any non-MS) webserver product from www.winfiles.com.
After spending hours trying to get PWS working under Windoze95, Xitami
installed and ran my scripts with NO intervention on my part. Brillig!
BTW, this should probably go to one of the *webserver* groups as it's not
strictly Perl-related.
AC.
kanak@pobox.com wrote:
: Folks have told me that they do run under PWS, but I don't know, I'm beginning
: to have my doubts. I'd do it under IIS, but it installs only on Windows 4.0
: Server edition and I'm using client. This is just a personal box and I don't
: own NT Server. Thanks though...
: In article <6ora15$6am$1@taliesin.netcom.net.uk>,
: "Clinton Gormley" <*clinton@consol.co.uk> wrote:
: > When I tried to do this with Personal Web Sever under Win95, Microsoft told
: > me that PWS wouldn't run Perl scripts. Don't know about NT?
: >
: > Why not use IIS?
: >
: > kanak@pobox.com wrote in message <6or7vh$fgl$1@nnrp1.dejanews.com>...
: > >Hi,
: > >
: > >If I'm in the wrong group, I apologize, and would appreciate it if someone
: > >would be able to direct me to a more appropriate group.
: > >
: > >I've been having a problem getting Perl scripts to run as cgi's under
: > Windows
: > >NT with Micro$oft Personal Web Server. The .pl files and .cgi files run
: > fine
: > >by hand. But when launched from the web server, the symptom is that the
: > web
: > >server will try to do an http transfer of a .pl file, and will whine about
: > >the .cgi file with a "%1 is not a valid Windows NT application.".
: > >
: > >-My two local guru's remember having this problem but don't remember how to
: > >get around it!
: > >
: > >-All directories in the Personal Web Server are checked execute.
: > >
: > >-I've added d:\perl\bin\perl.exe %s %s to
: > >My Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet
: > >\Services\W3SVC\Parameters\ScriptMap for .plx, .pl and .cgi
: > >
: > >-I've manually associated .pl and .cgi with the perl binary
: > >-I've run a little registry script like this:
: > >REGEDIT4
: > >
: > >[HKEY_CLASSES_ROOT\.PL]
: > >@ = "PL_auto_file"
: > >
: > >[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PL_auto_file]
: > >@ = ""
: > >
: > >[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PL_auto_file\shell]
: > >
: > >[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PL_auto_file\shell\open]
: > >@ = ""
: > >
: > >[HKEY_CLASSES_ROOT\PL_auto_file\shell\open\command]
: > >@ = "\"D:\\perl\\bin\\perl.exe\" %1 %*"
: > >
: > >
: > >Please if anybody has any ideas for this, I'd really like to know!
: > >
: > >-----== Posted via Deja News, The Leader in Internet Discussion ==-----
: > >http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
: >
: >
: -----== Posted via Deja News, The Leader in Internet Discussion ==-----
: http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 23 Jul 1998 00:43:06 GMT
From: mikep@rt66.com (mikep)
Subject: Re: Perl with SSI
Message-Id: <6p60uq$ejf$3@news.rt66.com>
In article <35B64FA1.B925A659@cse.unl.edu>
Ryan Morgan <rmorgan@cse.unl.edu> writes:
> is there anyway to enbed ssi directives within perl scripts? I know
> that you can set up which files are parsed for ssi using the SetHandler
> command (in the apache config.) , but when the html is generated from a
> perl script, (eg.. login.pl) the web server wont parse it since its
> not coming from a file with a .shtml extension. Anyone have a work
> around?
Not as far as I can tell. In other words do you mean the perl script
outputs content during a "web page" after having printed "Content-type:
text/html\n\n"? I tried just this thing once. If you think about it SSI
implies that the server processes the request _before_ posting any text
to the client. Once you pass the "Content-type" message to the client
you're client bound (and so the request won't be performed).
Besides, since you're in the guts of a script at the time anyhow, it
shouldn't be a big hairy deal to break out the code or snippets of it
to print out the text that would have been processed during the SSI in
the first place. At least that's the way I approached it.
Hope this helps.
===========================
Mike Powell
mikep@rt66.com
http://www.rt66.com/~mikep/
------------------------------
Date: Wed, 22 Jul 1998 18:25:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: specific character/position in string
Message-Id: <MPG.102030e956cf90e098973b@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy sent to Josh Kortbein
<kortbein@iastate.edu>.]
In article <6p5qgf$9kr$1@news.iastate.edu> on 22 Jul 1998 22:53:03 GMT,
Josh Kortbein <kortbein@iastate.edu> says...
...
> A comparison of some different ways to do it follows. I'm slightly
> confused as to why RINDEX2 took longer than RINDEX. Comments, anyone?
> I've not used Benchmark much.
You are not using it correctly, as you will see.
> Unsuprisingly, regexes are the fastest (and were the only unrecommended
> solution, oddly).
I was very surprised, since they always benchmark *slowest* when I
measure them.
> /home/kortbein% perl find.pl
> Benchmark: timing 1000000 iterations of REGEX, RINDEX, RINDEX2, SUBSTR...
> REGEX: 1 secs ( 0.97 usr 0.02 sys = 0.98 cpu)
> RINDEX: 4 secs ( 3.87 usr 0.02 sys = 3.88 cpu)
> RINDEX2: 5 secs ( 4.22 usr 0.02 sys = 4.23 cpu)
> SUBSTR: 2 secs ( 1.47 usr 0.00 sys = 1.47 cpu)
> /home/kortbein% cat find.pl
> #!/usr/local/bin/perl5
>
> use Benchmark;
>
> my $string = 'a' x 2999 . '.' . 'b';
> my $flag = 0;
> timethese(1000000, {
> 'REGEX' =>
> '$flag = 1 if $string =~ /\..$/',
> 'SUBSTR' =>
> '$flag = 1 if ("." eq substr($string, -2))',
> 'RINDEX' =>
> '$flag = 1 if (rindex($string, ".") eq length($string) - 2)',
> 'RINDEX2' =>
> '$flag = 1 if (rindex($string, ".") eq 2999)'
> });
> Question to more experienced readers: why does my code warn about
> use of an uninitialized variable in one of the timethese() evals
> if I run with -w? I can't see where the usage mentioned is.
> I thought it might have been substr(), since one can assign to
> it, but a separate test I ran had no problems with substr() being
> on the LHS or RHS of assignment.
-w is your friend and tells you where you have gone wrong (and what to
fix before posting your results :-).
One smart thing to do with benchmarks is to insert print statements in
the benchmark and run them one time only. You would have discovered that
the value of $string is undefined in your benchmark. No wonder the regex
ran fast!
I replaced your initializations by these:
use vars qw( $string $line );
$string = 'a' x 2999 . '.' . 'b';
$flag = 0;
Now the variables are global and the reults are quite different:
Benchmark: timing 200000 iterations of REGEX, RINDEX, RINDEX2, SUBSTR...
REGEX: 96 secs (39.57 usr 0.17 sys = 39.74 cpu)
RINDEX: 15 secs ( 5.95 usr 0.04 sys = 5.99 cpu)
RINDEX2: 12 secs ( 5.32 usr 0.02 sys = 5.34 cpu)
SUBSTR: 2 secs ( 1.32 usr 0.01 sys = 1.33 cpu)
I have a slower and heavier loaded machine than you (HP 9000/819).
Next, to eliminate issues as to that regex being compiled a zillion
times, I put each of the tests into a subroutine, which gets compiled
once only. The results were:
Benchmark: timing 200000 iterations of REGEX, RINDEX, RINDEX2, SUBSTR...
REGEX: 126 secs (44.60 usr 0.36 sys = 44.96 cpu)
RINDEX: 24 secs ( 8.86 usr 0.06 sys = 8.92 cpu)
RINDEX2: 22 secs ( 8.18 usr 0.06 sys = 8.24 cpu)
SUBSTR: 10 secs ( 4.26 usr 0.00 sys = 4.26 cpu)
Next, following a technique I learned here (from Abigail, IIRC) that
works in 5.004 but not earlier, I used anonymous subroutines:
Benchmark: timing 200000 iterations of REGEX, RINDEX, RINDEX2, SUBSTR...
REGEX: 114 secs (42.78 usr 0.24 sys = 43.02 cpu)
RINDEX: 26 secs ( 8.60 usr 0.06 sys = 8.66 cpu)
RINDEX2: 20 secs ( 7.51 usr 0.04 sys = 7.55 cpu)
SUBSTR: 10 secs ( 3.78 usr 0.03 sys = 3.81 cpu)
CONCLUSION:
'SUBSTR' rules (as always) and 'REGEX' loses big (as always).
Here is the final code, if anyone wants to verify any of this:
#!/usr/local/bin/perl5 -w
use Benchmark;
use vars qw( $string $flag );
$string = 'a' x 2999 . '.' . 'b';
$flag = 0;
timethese(200000, {
REGEX => sub { $flag = 1 if $string =~ /\..$/ },
SUBSTR => sub { $flag = 1 if ("." eq substr($string, -2)) },
RINDEX => sub { $flag = 1 if (rindex($string, ".") eq
length($string) - 2) },
RINDEX2 => sub { $flag = 1 if (rindex($string, ".") eq 2999) },
});
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 23 Jul 1998 02:15:32 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: specific character/position in string
Message-Id: <35B69E26.6FB71429@shaw.wave.ca>
[posted and mailed]
Larry Rosler wrote:
>
> CONCLUSION:
> 'SUBSTR' rules (as always) and 'REGEX' loses big (as always).
>
> Here is the final code, if anyone wants to verify any of this:
>
> #!/usr/local/bin/perl5 -w
> use Benchmark;
> use vars qw( $string $flag );
> $string = 'a' x 2999 . '.' . 'b';
> $flag = 0;
> timethese(200000, {
> REGEX => sub { $flag = 1 if $string =~ /\..$/ },
> SUBSTR => sub { $flag = 1 if ("." eq substr($string, -2)) },
> RINDEX => sub { $flag = 1 if (rindex($string, ".")
> eq length($string) - 2) },
> RINDEX2 => sub { $flag = 1 if (rindex($string, ".")
> eq 2999) },
> });
>
SUBSTR never matches though. It should be
$flag = 1 if ("." eq substr($string, -2, 1));
^^
This, of course, does not alter the benchmark.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Wed, 22 Jul 1998 19:44:49 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: specific character/position in string
Message-Id: <MPG.1020437d90aa042989778@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc; copy mailed to Rick Delaney
<rick.delaney@shaw.wave.ca>.]
In article <35B69E26.6FB71429@shaw.wave.ca> on Thu, 23 Jul 1998 02:15:32
GMT, Rick Delaney <rick.delaney@shaw.wave.ca> says...
...
> SUBSTR never matches though. It should be
> $flag = 1 if ("." eq substr($string, -2, 1));
> ^^
> This, of course, does not alter the benchmark.
Yes. I just cut and pasted the original code. I tested it cursorily for
sanity (which is how I discovered the basic flaw), but I missed that bug.
I printed $string but didn't bother with $flag.
Of course, as you say, this really doesn't affect anything. The main
point was how bogus the benchmark was in the first place. When you can
locate things by position in a string, SUBSTR clobbers REGEX every time.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 23 Jul 1998 02:18:10 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: temp directory for both unix and windows platform
Message-Id: <6p66h2$325$1@nswpull.telstra.net>
In article <35B66C8D.6C69@erols.com>,
Ian <imoore-NOSPAM@erols.com> writes:
> I beleive both Unix and Windoze have an enviornment variable called
> "TEMP"
It's not part of dos, unix or windoze. It's up to the application to
read the appropriate environment variable. Some will read TMP, others
will read TEMP. Others don't bother with any of this.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | You can't have everything, where would
Commercial Dynamics Pty. Ltd. | you put it?
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 3229
**************************************