[18455] in Perl-Users-Digest
Perl-Users Digest, Issue: 623 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 4 00:06:00 2001
Date: Tue, 3 Apr 2001 21:05:13 -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: <986357112-v10-i623@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 3 Apr 2001 Volume: 10 Number: 623
Today's topics:
Re: All-time "answer golf" winner! (was Re: array contr <rick.delaney@home.com>
Re: Deleting one line from a file <david_j_findlay@yahoo.com.au>
Re: Deleting one line from a file <david_j_findlay@yahoo.com.au>
Re: Deleting one line from a file (Gwyn Judd)
Re: Disguising Perl scripts (Iain Chalmers)
Re: Force Integer Division?? (Tad McClellan)
Re: Free perl interpreter <no@spam.net>
Graphical Counter interpretation <mlacey@ipimus.com.au>
Re: Graphical Counter interpretation <mjcarman@home.com>
help needed with sorting Hash <afshin.akbari@sympatico.ca>
Re: help needed with sorting Hash <derek@ludwig.com>
Re: help needed with sorting Hash (John Joseph Trammell)
Re: How can I determine if a file descriptor is still a <goldbb2@earthlink.net>
Re: how to create a new user by script? (Chris Fedde)
localtime and Win32: The april fool's bug rajseshadri@SPAMSUCKSyahoo.com
Re: Newbie: keep on matching until end of string <goldbb2@earthlink.net>
Re: Perl CGI and GD?? <goldbb2@earthlink.net>
Perl Timer! <hernux@etherac.com.ar>
Re: Please Flame my Benchmark: open vs. cat (Dave Bailey)
Re: Please Flame my Benchmark: open vs. cat (Gwyn Judd)
Re: regular expression aa versus a{2} <don.koks@defence.gov.auREMOVE_CAPITALS>
Re: regular expression aa versus a{2} (John Joseph Trammell)
Re: Serverside + Detect Browser Plugin <goldbb2@earthlink.net>
Re: Uninitialized Value warnings with DBD::CSV 0.1024 ( <webmaster@webdragon.unmunge.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 04 Apr 2001 02:34:18 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: All-time "answer golf" winner! (was Re: array control issues)
Message-Id: <3ACA8B68.E3EAD632@home.com>
Uri Guttman wrote:
>
> look up the range operator in perlfunc. study it. you will then know.
^^^^^^^^
perlop
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Wed, 4 Apr 2001 21:26:14 +1000
From: David Findlay <david_j_findlay@yahoo.com.au>
Subject: Re: Deleting one line from a file
Message-Id: <wwuy6.8618$45.50833@newsfeeds.bigpond.com>
--nextPart2254674.VVIhKElGaq
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8Bit
> What is wrong with the answer to PerlFAQ5:
> How do I change one line in a file/delete a line in a file/insert a
> line
> in the middle of a file/append to the beginning of a file?
Okay using the FAQ method now. But I have a problem that it doesn't remove
anything it just copies the whole lot at the moment. I feed all the lines
that need removal from the file to an array, then I want to print unless
the name is in the array. I have attached the code here. Could someone
please help me fix the problem? I am going to get that Orielly's
Programming in Perl as soon as I can.
David
--nextPart2254674.VVIhKElGaq
Content-Type: application/x-perl; name="blocking.pl"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="blocking.pl"
IyEvdXNyL2Jpbi9wZXJsCgp1c2UgQ0dJIHF3LzpzdGFuZGFyZC87CiRxdWVyeSA9IG5ldyBDR0k7
CgojVGhpcyBpcyBhIHNjcmlwdCB0byBlZGl0IHRoZSBmaWxlcyBzdG9wX2NsaWVudHMgYW5kIHN0
b3BfZXh0IG9uIGEgc3F1aWQgc2VydmVyCiRjbGllbnRmaWxlID0gIi91c3IvbGliL2NnaS1iaW4v
YmxvY2tpbmcvc3RvcF9jbGllbnRzIjsKJGV4dGZpbGUgPSAiL3Vzci9saWIvY2dpLWJpbi9ibG9j
a2luZy9zdG9wX2V4dCI7CgppZiAocGFyYW0oKSkgewogIGZvcmVhY2ggKCRxdWVyeS0+cGFyYW0o
KSkgeyAkcmVtY2x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CBmcm9tIGRvd25sb2FkaW5nIGZpbGVzIHdp
dGggdGhlIGV4dGVuc2lvbnMgYmVsb3c8cD5cbiI7CnByaW50ICI8Zm9ybSBtZXRob2Q9J3Bvc3Qn
IGFjdGlvbj0naHR0cDovLzE5Mi4xNjguMC4zL2NnaS1iaW4vYmxvY2tpbmcucGwnPlxuIjsKcHJp
bnQgIjx0YWJsZSBib3JkZXI9MT48dHI+PHRkPjxiPklQIEFkZHJlc3M8L2I+PC90ZD48dGQ+PGI+
UmVtb3ZlPC9iPjwvdGQ+PC90cj5cbiI7CgojUmVhZCBmaWxlIGluCm9wZW4gQ0xJRU5UUywgIiRj
bGllbnRmaWxlIiBvciBkaWUgIkNvdWxkbid0IE9wZW4gJCEiOwokY291bnQxID0gMDsKd2hpbGUo
PENMSUVOVFM+KSB7CiAgJGNvdW50MSA9ICRjb3VudDEgKyAxOwogICRib3huYW1lPSAicmVtb3Zl
Ii4kY291bnQxOwogIHByaW50ICI8dHI+PHRkPiI7CiAgcHJpbnQgJF87CiAgcHJpbnQgIjwvdGQ+
PHRkPjxpbnB1dCB0eXBlPWNoZWNrYm94IG5hbWU9IjsgCiAgcHJpbnQgIiRib3huYW1lIjsgCiAg
cHJpbnQgIj5SZW1vdmU8L3RyPlxuIjsKfQpjbG9zZSBDTElFTlRTOwpwcmludCAiPC90YWJsZT48
YnI+XG4iOwoKcHJpbnQgIkFkZCBuZXcgY2xpZW50OiA8aW5wdXQgdHlwZT10ZXh0IHNpemU9MTUg
bmFtZT1hZGRjbGllbnQ+PGJyPlxuIjsKcHJpbnQgIjxpbnB1dCB0eXBlPXN1Ym1pdCB2YWx1ZT0n
QXBwbHknPlxuIjsKCnByaW50ICI8L0JPRFk+PC9IVE1MPlxuIjsK
--nextPart2254674.VVIhKElGaq--
------------------------------
Date: Wed, 4 Apr 2001 21:32:23 +1000
From: David Findlay <david_j_findlay@yahoo.com.au>
Subject: Re: Deleting one line from a file
Message-Id: <hCuy6.8621$45.50833@newsfeeds.bigpond.com>
> Here's a quickie for you, if you promise to read the FAQ:
>
> while(<>) { print unless /what I don't want matched/ }
>
> This example assumes STDIN for input and STDOUT for output,
> but you can change that in any text editor.
So can I go
while(<FILE>) { print unless @array }
Where array contains an array of the values I want to remove.
David
------------------------------
Date: Wed, 04 Apr 2001 03:50:19 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Deleting one line from a file
Message-Id: <slrn9cl6fp.pvn.tjla@thislove.dyndns.org>
I was shocked! How could David Findlay <david_j_findlay@yahoo.com.au>
say such a terrible thing:
>> Here's a quickie for you, if you promise to read the FAQ:
>>
>> while(<>) { print unless /what I don't want matched/ }
>>
>> This example assumes STDIN for input and STDOUT for output,
>> but you can change that in any text editor.
>
>So can I go
>
>while(<FILE>) { print unless @array }
>
>Where array contains an array of the values I want to remove.
Did you even try it? Don't answer that, because I know you didn't. Do
you have a book on Perl? I suggest you get one.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Printers do it without wrinkling the sheets.
------------------------------
Date: Wed, 04 Apr 2001 13:53:04 +1000
From: bigiain@mightymedia.com.au (Iain Chalmers)
Subject: Re: Disguising Perl scripts
Message-Id: <bigiain-0404011353040001@bigman.mighty.com.au>
In article <xyXx6.7682$45.45171@newsfeeds.bigpond.com>, "Gregory Toomey"
<gtoomey@usa.net> wrote:
>One way would be to encrypt the scripts, then decrypt and run them "on the
>fly".
>
>DES, or even "rot 13" (or better still - write your own rot 128) spring to
>mind as suitable encryption algorithms.
I wouldn't use straigh DES, triple-DES is more secure...[0]
Personally, I use dual rounds of ROT13 in combination with a copyright notice...
big
[0] yeah, I know, it was just a setup for the dual ROT13 gag, OK? <GRIN>
------------------------------
Date: Tue, 3 Apr 2001 21:12:08 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Force Integer Division??
Message-Id: <slrn9ckt78.f1j.tadmc@tadmc26.august.net>
Rickard <d96-rsa@nada.kth.se> wrote:
>I read
Where was it that you read that?
>that a division of two integers should produce an integer
>answer but that isn't true on my computer.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 04 Apr 2001 03:40:11 GMT
From: "Misanthrope" <no@spam.net>
Subject: Re: Free perl interpreter
Message-Id: <vIwy6.3477$B84.294317@newsread1.prod.itd.earthlink.net>
Nice April Fools joke. Half a dozen people went for it.
"Michael Farragher" <mick@farragher77.freeserve.co.uk> wrote in message
news:9a7uol$v0h$1@newsg3.svr.pol.co.uk...
> Can anyone suggest where I can get a free perl interpreter from ?
>
> TIA,
>
> Michael Farragher
>
>
>
------------------------------
Date: Wed, 4 Apr 2001 11:12:24 +1000
From: "M. Lacey" <mlacey@ipimus.com.au>
Subject: Graphical Counter interpretation
Message-Id: <3aca748a$1@news.iprimus.com.au>
This may seem like a dumb question, but I would like to know the
relationship of the code below to the output.
The code generates a white number on a black background, and would like to
know what the numerical format of each line represents to achieving the
color and each number.
("c3 99 99 99 99 99 99 99 99 c3", # 0
"cf c7 cf cf cf cf cf cf cf c7", # 1
"c3 99 9f 9f cf e7 f3 f9 f9 81", # 2
"c3 99 9f 9f c7 9f 9f 9f 99 c3", # 3
"cf cf c7 c7 cb cb cd 81 cf 87", # 4
"81 f9 f9 f9 c1 9f 9f 9f 99 c3", # 5
"c7 f3 f9 f9 c1 99 99 99 99 c3", # 6
"81 99 9f 9f cf cf e7 e7 f3 f3", # 7
"c3 99 99 99 c3 99 99 99 99 c3", # 8
"c3 99 99 99 99 83 9f 9f cf e3"); # 9
many thanks
Michael
michael_faulkes@hotmail.com
------------------------------
Date: Wed, 04 Apr 2001 02:43:55 GMT
From: Michael Carman <mjcarman@home.com>
Subject: Re: Graphical Counter interpretation
Message-Id: <3ACA8A5C.F0976548@home.com>
"M. Lacey" wrote:
>
> This may seem like a dumb question,
Not necessarily, but it doesn't seem to have anything to do with Perl.
> I would like to know the relationship of the code below to the
> output. The code generates a white number on a black background,
That "code" doesn't do anything. It's just an array if strings in a void
context.
> and would like to know what the numerical format of each line
> represents to achieving the color and each number.
To me it looks like a bunch of hex values -- ASCII maybe -- but I'm not
aware of anything special about those ones. They aren't escape sequences
or color codes for any terminal I'm aware of. Presumably it all means
something to the application that's using the data. (You've told us
nothing about it, so we can only guess what it might be.) I suggest you
follow the code trail to see how it's used.
-mjc
------------------------------
Date: Wed, 04 Apr 2001 02:20:57 GMT
From: afshin akbari <afshin.akbari@sympatico.ca>
Subject: help needed with sorting Hash
Message-Id: <3ACA0608.86016145@sympatico.ca>
All,
Is there a way to to sort and print a hash based on the
value field.
suppose we have,
%hash (a => 7,
b => 1,
c => 3);
result should be:
%hash (b => 1,
c => 3,
a => 7);
Thanks in advance.
aa-
------------------------------
Date: Wed, 04 Apr 2001 02:54:31 GMT
From: "Derek Ludwig" <derek@ludwig.com>
Subject: Re: help needed with sorting Hash
Message-Id: <x1wy6.5463$l5.4821606@newsfeed1.thebiz.net>
Reverse the key/values:
%hash (7 => a, 1 => b, 3 => c)
and print the "value" first. You would have to work out a means of handling
multiple keys with the same value, either with a list or some sort of
string.
-- D
------------------------------
Date: Wed, 04 Apr 2001 03:51:35 GMT
From: trammell@bayazid.hypersloth.invalid (John Joseph Trammell)
Subject: Re: help needed with sorting Hash
Message-Id: <slrn9cl4gm.cv5.trammell@bayazid.hypersloth.net>
On Wed, 04 Apr 2001 02:20:57 GMT, afshin akbari wrote:
> Is there a way to to sort and print a hash based on the
> value field.
This is answered in Perl FAQ 4. In short:
@sorted_keys = sort { $h{$a} cmp $h{$b} } keys %h;
------------------------------
Date: Wed, 04 Apr 2001 03:02:12 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How can I determine if a file descriptor is still available ???
Message-Id: <3ACA8F93.EA7F6DE3@earthlink.net>
C. Lechner wrote:
>
> Hallo,
>
> I've written the following code and it works fine
> till the other end of the connection closes the
> socket:
>
> socket (C_SOCK, PF_INET, SOCK_STREAM, $proto);
>
> while (1)
> {
> my $l = sysread SOCK, $data, 32;
> if ($l)
> {
> syswrite C_SOCK, $data;
> }
> print "#";
> }
>
> I'd like the code to leave the while-loop when
> the other end closes the connection instead of
> bombing STDOUT w/ hashes. How can I do this ?
Simply exit the loop if $l returns 0.
--
Sometimes the journey *is* its own reward--but not when you're trying to
get to the bathroom in time.
------------------------------
Date: Wed, 04 Apr 2001 04:04:32 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: how to create a new user by script?
Message-Id: <k3xy6.585$T3.192168960@news.frii.net>
In article <CUry6.81417$Lm2.10053913@news0.telusplanet.net>,
MGD <mgd@converging.net> wrote:
>I am trying to automate setting up web pages and new users on a web and mail
>server. I have scripted the web page set up for apache, but I am stumpted as
>to how to specify an encrypted password for a new user. I can edit the vipw
>file but, of course, any change to the pw would be in encrypted form. Any
>hints or urls...?
>
>I am using FreeBSD 3.4. I usually use the adduser util to manually create a
>user. A rather tedious process.
>
Two things. First upgrade your FreeBSD to something recent 4.2 is the
RELEASE version.
Second encripting a (des) password for use in /etc/master.password is trivial.
perl -le 'print crypt("password", "salt");'
I'm sure that you can adapt this to your needs. I've not come
across a similar (Perl) technique for the crypt-md5 format sometimes
used on FreeBSD but I'm sure that it is also quite doable.
--
This space intentionally left blank
------------------------------
Date: Wed, 04 Apr 2001 01:47:23 GMT
From: rajseshadri@SPAMSUCKSyahoo.com
Subject: localtime and Win32: The april fool's bug
Message-Id: <L2vy6.1131$jz.98266@www.newsranger.com>
I just ran into this while addressing a *really* bizarre bug having to do with
daylight savings.
You can find the full post on bugtraq, or any of the windows groups. I am only
posting the relevant details
Date: Thu, 7 Jan 1999 10:18:33 +0100
From: Richard M. Smith
To: NTBUGTRAQ@LISTSERV.NTBUGTRAQ.COM
Subject: The Windows "April Fools 2001" bug
January 7, 1999
I have discovered a serious bug in Windows which will cause
many Windows applications to give the incorrect time starting
on April 1, 2001. Although this new bug is not technically a Y2K
bug, it is similar because programs will fail on a particular
day in the next century.
The bug causes Windows applications to give times which are off by one hour
even though the Windows clock shows the correct time. The bug will continue
for one week until April 8th of 2001, when applications will again show the
correct time. The bug occurs under Windows 95, 98, and NT.
The problem is caused by the Visual C++ runtime library being
confused and assuming that daylight saving time doesn't start until
April the 8th. In fact, daylight saving time starts on April 1 in
the year 2001. The confusion appears to be caused by the fact that
April 1 falls on a Sunday in the year 2001. The same bug occurs
in other years where April 1 also falls on a Sunday. The last time this
happened was in 1990 and after 2001 it will occur again in 2007. If April 1
falls on any other day of the week, the bug does not occur.
I reported the bug to Microsoft on Jan. 5th and got confirmation of
from them on the evening of Jan. 6th. At the present time, Microsoft told
me that they don't know when a fix will be available for the bug.
For some applications, users should be able to fix the
problem by downloading a new version of the Visual C++ runtime
library DLL, MSVCRT.DLL. Since the DLL now ships as part of Windows,
I would assume the fixed DLL will be available of the Windows Update
site.
Unfortunately not all applications can be corrected with a new release of
MSVCRT.DLL. Any applications which statically links with the Visual C++
runtime will have to be fixed by the application vendor. Users will
have to download the new releases of these kinds of applications.
In my testing, I believe that the bug was introduced in version 4.1 of
Visual C++. It is present in versions 4.2, 5.0, and 6.0 according to
my testing.
At the present time, the bug has been confirmed only in North American
time zones. Outside North America it is unknown if the same bug
exists or not. If it does exists, it may occur on different days
and different years.
I have written a small program in C that tests for the problem.
The source code for the test program is attached to the end of this
message.
This "April Fools 2001" bug is present in the localtime() function, but
is probably also in other functions defined in the C language "time.h"
header file.
-Raj Seshadri
rajseshadri@SPAMSUCKSyahoo.com
to email me, please remove the obligatory spamblock
------------------------------
Date: Wed, 04 Apr 2001 03:48:31 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Newbie: keep on matching until end of string
Message-Id: <3ACA9A6E.13F4569F@earthlink.net>
David Wake wrote:
>
> Brad Baxter <bmb@ginger.libs.uga.edu> writes:
>
> > On 28 Mar 2001, David Wake wrote:
> > > Many thanks for replies. What do I do if the string has a
> > > non-repeated introduction? Say, for example, that I want to
> > > search for the string "START" and then copy every subsequent word
> > > into an array.
> > >
> > > Thanks for helping ignorant newbie,
> >
> > Do you have an actual string that you want to parse this way? It
> > sounds to me like you've changed the subject. What have you tried?
> >
>
> I guess my initial query was a bit too general -- apologies. I am
> actually trying to parse an HTML page. I want to look for a string
> (call is "START") and after that search for and store a pattern of
> regexps which keeps repeating.
>
> So you could imagine the string having the following structure:
>
> [trash]START[trash](INTERESTING_SUBSTRING[trash])
>
> where the part in parentheses is repeated indefinitely.
>
> I want to store all the INTERESTING_SUBSTRINGs
This code is untested, but should do what you want:
my ($x) = $string =~ /START(.*)/; # captures everything after START
my @aha = $x =~ /(INTERESTING)/g; # captures all INTERESTING things
All of the parens above are important. The ones around $x cause the
stuff to the right of the = to be evaluated in list context. The ones
around the .* cause what it matches to be captured. The ones around
INTERESTING cause each thing which matches the INTERESTING pattern to be
captured and returned to be put into the aha array.
--
Sometimes the journey *is* its own reward--but not when you're trying to
get to the bathroom in time.
------------------------------
Date: Wed, 04 Apr 2001 02:03:04 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl CGI and GD??
Message-Id: <3ACA81B8.E404B8EE@earthlink.net>
Bryan Coon wrote:
>
> Is there any way to generate images directly with GD to stdout when
> using cgi in a form? I have tried several tricks, none work.
>
> What I need is to have an image generated on the fly, and embedded in
> a form. This is not working, as the only documentation I found does
> describe how to do this, ( binmode STDOUT; print STDOUT $im->png(); )
> but this only works if you have an appropriate header (Content-type:
> image/png or whatever). I am pretty sure that I HAVE to use
> multipart:form-data here. Is this possible? Maybe I have to call a
> separate script with my image tag?
>
> Mainly I want to avoid littering my drive with a ton of little images,
> each of which will be unique (yuck!). I think it is much cleaner to
> do it inline.
>
> Thanks!
> Bryan
What I *think* you want is a multipart/something (not form-data, I think
it was either "mixed" or "alternative") mimetype, with the first part
being html, and the following parts being the images which the html is
supposed to show. I have once recieved html email which did this, and
managed to get it to work properly, but I no longer have it around, so
am not quite sure of the exact syntax. The html had something like <img
src="cid:asdf"> and in the mime header of the other part, it had
something like "Content-id:asdf".
Of course, whether your viewers browsers will support that, I dunno.
--
Sometimes the journey *is* its own reward--but not when you're trying to
get to the bathroom in time.
------------------------------
Date: Tue, 3 Apr 2001 23:23:17 -0300
From: "Hernux" <hernux@etherac.com.ar>
Subject: Perl Timer!
Message-Id: <9ae0kf$1oc$1@taliesin.netcom.net.uk>
Hi, is there a way to make a timer in perl???
like settimeout function in javascript.......
thanx
------------------------------
Date: 04 Apr 2001 01:55:12 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: Please Flame my Benchmark: open vs. cat
Message-Id: <slrn9cklep.71p.dave@sydney.daveb.net>
On Tue, 03 Apr 2001 23:46:13 -0000, Chris Stith
<mischief@velma.motion.net> wrote:
>Dave Bailey <dave@sydney.daveb.net> wrote:
>> On Tue, 3 Apr 2001 20:34:07 +0000 (UTC), Abigail <abigail@foad.org> wrote:
>>>Uri Guttman (uri@sysarch.com) wrote on MMDCCLXXII September MCMXCIII in
>>><URL:news:x78zlhvs70.fsf@home.sysarch.com>:
>>>;; >>>>> "A" == Abigail <abigail@foad.org> writes:
>>>;;
>>>;; A> I find the Benchmark not very useful. One doesn't repeatedly read
>>>;; A> the same file over and over again in a typical program.
>>>;;
>>>;; A> Furthermore, you are banchmarking the repeat read of a single
>>>;; A> file. A good Benchmark would bench a whole range of file sizes
>> [...]
>
>[snip]
>
>>>If I need a string 10,000 times in a program, I would not read it
>>>10,000 times from a file and benchmark which is the fastest.
>>>
>>>I'd redesign my program to something less absurd.
>
>> Your posts indicate that you don't understand what a benchmark is, nor
>> do you understand why the poster originally wrote this particular one.
>
>That is a pretty drastic conclusion to draw from such little context.
>This is especially true since Abigail is one of the more respected
>regulars in the group.
Not really. Most people misuse and/or misinterpret benchmarks, in
addition to merely creating useless ones.
>The fact that Abigail doesn't think it's normal to read the same
>file for contents several thousand times in a program doesn't mean
>she doesn't recognize the value of a benchmark.
I didn't say that. I was referring to her implication that the program
which inspired the benchmark did this ("If I need a string 10,000 times
in a program..."), and should be redesigned. That was never indicated
by the original poster. Perhaps all the program did was slurp a file
into a scalar and then exit. It doesn't matter. The question was, is it
faster to perform this task by backticking cat, or by slurping from Perl?
>She just thinks the benchmark is silly, considering the task isn't one
>that will be done in any real program...
The repetition merely serves to magnify the time difference between the
two methods to the point where it is resolvable. There is no implication
that this would occur in a "real" program. Suppose I write a benchmark to
compare floating point multiplication with floating point division to
convince someone that the former is faster. There are lots of situations
in computational physics where the inner loop of a computation includes
a division by something (say, x) which is computed in an outer loop. Such
a computation can be made faster by computing the reciprocal of x (call it
y) in the outer loop and replacing the inner-loop division by x with a
multiplication by y. Depending on what's going on in the inner loop, the
savings can be quite substantial. But the benchmark itself might be very
unnatural and you might look at it and say "I would never write a program
which does this. I would redesign my program instead". But the program
in question isn't the benchmark, it's the computation which had the division
in the inner loop. You can't always just redesign things like that.
>I think if you want to know the difference between cat and open in
>this controlled environment, the benchmark is fine. If you want to
>measure real-world performance, you need to do as Abigail suggests
>by feeding it several hundred or a few thousand different files.
>In the latter case, you need to remember that you're benchmarking
>your disk susbsystem more than your program. If you want the benchmark
>to be more relevant, it needs to be rewritten to do something a real
>program is likely to do.
I believe that "real-world performance" and "benchmark" are, necessarily,
contradictions. This is the crux of my disagreement with you and Abigail.
A benchmark which measures some inscrutable combination of many different
things tells me much less than several benchmarks, each of which measures
a specific thing. In the case where you read hundreds of thousands
of different files by cat and by open, you're testing your file system,
your kernel, various system calls, and your malloc implementation (cat
allocates memory for input and output buffers). I think this is overkill.
cat and open are not going to differ at all in certain respects such as
the file system's efficiency, so why is it necessary to have files all over
the disk in *this comparison*? All this does is dilute the difference
between the two methods by adding a constant time to both tests. As for
using different size files, that depends on the program which inspired the
benchmark. What if all the files are the same size? What if it's the same
exact file on the same exact loction in disk, but it gets rewritten every
5 seconds by some other process? You can't just blindly say, "this is
what you need to do to get a realistic benchmark", because what's realistic
varies from one situation to the next.
That said, I believe that this particular benchmark (cat vs open) is
entirely unnecessary, for reasons which are obvious to most of us, but
apparently not to the original poster's coworkers. It's like telling
someone "X is positive, Y is also positive, is X + Y greater than X?"
and having them tell you, "No, you've got it backwards".
--
Dave Bailey
davidb54@yahoo.com
------------------------------
Date: Wed, 04 Apr 2001 04:00:24 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Please Flame my Benchmark: open vs. cat
Message-Id: <slrn9cl72m.pvn.tjla@thislove.dyndns.org>
I was shocked! How could Dave Bailey <dave@sydney.daveb.net>
say such a terrible thing:
>The repetition merely serves to magnify the time difference between the
>two methods to the point where it is resolvable. There is no implication
But that isn't realistic. If you cannot discern a difference with
realistic benchmarks so that you have to modify them in unnatural ways
(such as reading in the same file 10000 times) then that suggests to me
that the two things you are trying to compare really aren't that
different in performance. Perhaps if you could show me that opening a
number of different sized files spread over different disks showed a
consisitent noticable speed increase, then that would be a worthwhile
benchmark. Oh wait, that was what Abigail was saying before now wasn't
it?
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The important thing is not to stop questioning.
------------------------------
Date: Wed, 04 Apr 2001 13:25:41 +0930
From: Don Koks <don.koks@defence.gov.auREMOVE_CAPITALS>
Subject: Re: regular expression aa versus a{2}
Message-Id: <3ACA9B3D.82D20011@defence.gov.auREMOVE_CAPITALS>
Thanks people, I go with the reply that said my perl is broken. Here is a
run of the code:
~/Perl: cat zaab.pl
#!/usr/bin/perl -w
if ("zaab" =~ /([^a]*)(a{2})b/) { print "1: $1, $2\n"; }
if ("zaab" =~ /([^a]*)(aa)b/) { print "2: $1, $2\n"; }
if ("zaab" =~ /([^a]*)(a{2})/) { print "3: $1, $2\n"; }
~/Perl: zaab.pl
2: z, aa
3: z, aa
~/Perl:
How's that?
Don
------------------------------
Date: Wed, 04 Apr 2001 04:04:25 GMT
From: trammell@bayazid.hypersloth.invalid (John Joseph Trammell)
Subject: Re: regular expression aa versus a{2}
Message-Id: <slrn9cl58o.d11.trammell@bayazid.hypersloth.net>
On Wed, 04 Apr 2001 13:25:41 +0930, Don Koks wrote:
[wacky stuff snipped]
> How's that?
I'd offer an opinion but I'm out of my depth.
What does perl -V say?
------------------------------
Date: Wed, 04 Apr 2001 01:25:30 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Serverside + Detect Browser Plugin
Message-Id: <3ACA78E9.277EA51E@earthlink.net>
jtjohnston wrote:
>
> Hi, I failed at this mixing JS and SSI script. So this is no longer a
> Javascript question.
>
> So I'm wondering, can Perl detect browser plugins? It can read
> cookies!
>
> If so I want to detect the RealAudio plugin and return the contents of
> plugin.txt in the browser, if not return a message.
The thing to do is use two parts: javascript *and* perl. Have the
browser-side javascript detect the plugin, and store whether the plugin
exists in a cookie. Then the server-side perl looks at the cookie, and
writes the page however you want.
--
Sometimes the journey *is* its own reward--but not when you're trying to
get to the bathroom in time.
------------------------------
Date: 4 Apr 2001 02:41:41 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Uninitialized Value warnings with DBD::CSV 0.1024 (mildly urgent)
Message-Id: <9ae1l5$n0g$0@216.155.33.72>
In article <9aal4v$6qn$0@216.155.32.18>,
"Scott R. Godin" <webmaster@webdragon.unmunge.net> wrote:
| just out of curiosity (and since a message to someone else reminded me
| that I could also do this :) I checked my weblogs with tail -f to see if
| anything shows up that I was unaware of with one of my scripts, and lo!
| there's about 7300 lines of this:
|
| [Mon Apr 2 14:24:09 2001] ncmapslistdbi.cgi: Use of uninitialized value
| at /opt/lib/perl5/site_perl/DBD/CSV.pm line 197.
| [Mon Apr 2 14:24:09 2001] ncmapslistdbi.cgi: Use of uninitialized value
| at /opt/lib/perl5/site_perl/DBD/CSV.pm line 197, <GEN1> chu
| nk 1.
Hmm.. apparently the version on the ISP is slightly newer than mine ..
note change below
| the offending code section:
| -=-
| package DBD::CSV::Table;
|
| @DBD::CSV::Table::ISA = qw(DBD::File::Table);
|
| sub fetch_row ($$) {
| my($self, $data) = @_;
| my $fields;
| if (exists($self->{cached_row})) {
| $fields = delete($self->{cached_row});
| } else {
undef $!; ### <-- the offending line 197?
(according to the line numbering in less, anyway.
I'm still stuck on this, and *any* assistance would still be much
appreciated.
| my $csv = $self->{csv_csv};
| local $/ = $csv->{'eol'};
| $fields = $csv->getline($self->{'fh'});
| if (!$fields) {
| die "Error while reading file " . $self->{'file'} . ": $!" if $!;
| return undef;
| }
| }
| $self->{row} = (@$fields ? $fields : undef);
| }
| -=-
| I'm sure there's a reason for this -- but not 100% certain as to what.
|
| the script body itself can be viewed here, in the most recent version
|
| <http://216.155.0.50/~sgodin/misc/codesample.htm>
|
| (too long to post here)
|
| I looked at my code again and cannot really see where this might be
| coming from. ANY help would be appreciated.. I'm QUITE sure my ISP would
| prefer and appreciate that I don't fill their weblogs with 7300 lines of
| this crap every time my script gets accessed. :/
|
| Any assistance appreciated.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
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 V10 Issue 623
**************************************