[9219] in Perl-Users-Digest
Perl-Users Digest, Issue: 2815 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 8 17:07:11 1998
Date: Mon, 8 Jun 98 14:01:41 -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 Mon, 8 Jun 1998 Volume: 8 Number: 2815
Today's topics:
Serving perl to multiple platforms/architectures justin_lloyd@my-dejanews.com
Re: Setting @INC as needed <rootbeer@teleport.com>
Re: Skipping iterations in while ptimmins@netserv.unmc.edu
Re: Skipping iterations in while (Abigail)
Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
Re: substitution not working (Steve Linberg)
Re: what's a cross-platform \n please? (Chip Salzenberg)
Re: Why is there no "in" operator in Perl? (Snowhare)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 08 Jun 1998 19:58:21 GMT
From: justin_lloyd@my-dejanews.com
Subject: Serving perl to multiple platforms/architectures
Message-Id: <6lhfot$q82$1@nnrp1.dejanews.com>
I am a Unix sysadmin, and I'm trying to reorganize how we serve perl.
Currently, we have /pub/perl $OSNAME switched, so from a Sun machine it mounts
server:/export/PUB/PERL_SW/SunOS, and from Irix,
server:/export/PUB/PERL_SW/IRIX (or Irix, or IRIX64). However, this is only
version 5.003. I want to serve both 5.003 and 5.004, with 5.004 as the
default. This was my first idea for our auto_pub map:
perl -rw,intr,soft \
/ server:/export/PUB/PERL_SW/PERL_DIR \
/5.003/bin server:/export/PUB/PERL_SW/$OSNAME/5.003/bin \
/5.004/bin server:/export/PUB/PERL_SW/$OSNAME/5.004/bin
which allows me to serve different binaries, while allowing the libraries and
manpages to be the same for each version. However, then there is the problem
of different processor types for SGI machines, leading to different
architectures. For example, we have IP22-irix, IP27-irix, IP30-irix, and
IP32-irix (not to mention sun4-solaris, and possibly HP-UX and osf1 in the
future). This means that I will have to build several copies of any modules
that are installed and have architecture-dependant code, such as Net and Tk.
Also, the main libraries that are built with the main code will also have to
be built for each platform/architecture.
So my question is this: Has anyone come up with a solution to this problem of
serving so many copies of libraries and binaries that would probably work
better than what I've come up with.
I read this group constantly, but I would greatly appreciate an email copy of
any replies to this, just so I don't miss anything. My slightly mangled
address is jlloydATharrisDOTcom.
Thanks,
JcL
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 08 Jun 1998 19:11:37 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Setting @INC as needed
Message-Id: <Pine.GSO.3.96.980608120559.29617v-100000@user2.teleport.com>
On 5 Jun 1998, Morgan Fletcher wrote:
> Is it a valid strategy to try to deduce the location of the script and
> then set @INC accordingly?
Generally, no. You can't always find out the location of the script. But
each machine's perl binary should know where that machine's modules will
be stored.
But, if nothing else will work, you can be sure that some module (let's
call it localINC.pm) is findable on each machine. That module can 'use
lib' as needed to fix things up for that machine's environment. Of course,
you'll have to re-write that module for each machine, so it's not as nice
a solution as simply ensuring that each machine's perl is properly
configured.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 08 Jun 1998 19:10:58 GMT
From: ptimmins@netserv.unmc.edu
Subject: Re: Skipping iterations in while
Message-Id: <6lhd01$mi9$1@nnrp1.dejanews.com>
In article <357C1153.750F836F@mail1.csun.edu>,
olm@mail1.csun.edu wrote:
>
> How can I skip the very first, (or for that matter "any") iteration of a
> while loop.
>
> I am reading in the output of a unix command, the first line of which I
> don't need, and I need to
> ignore somehow. Is there a control statement in perl that would skip a
> particular iteration in the w
> while loop.
>
> Thanks in advance for your help.
>
> Sincerely,
>
> ovanes m.
>
How about
while (<>) {
unless ($. == 1) {
$your_code = "here";
# etc.
}
}
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 8 Jun 1998 20:16:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Skipping iterations in while
Message-Id: <6lhgq0$c15$2@client3.news.psi.net>
ptimmins@netserv.unmc.edu (ptimmins@netserv.unmc.edu) wrote on MDCCXLII
September MCMXCIII in <URL: news:6lhd01$mi9$1@nnrp1.dejanews.com>:
++
++ How about
++
++ while (<>) {
++ unless ($. == 1) {
++ $your_code = "here";
++ # etc.
++ }
++ }
But that would mean testing $. for every line on input.
<>; # Skip first line.
while (<>) {
# Your code here.
}
(Assuming there is at least one line).
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: 8 Jun 1998 19:58:27 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <6lhfp3$pl$2@info.uah.edu>
Following is a summary of articles spanning a 7 day period,
beginning at 01 Jun 1998 19:25:42 GMT and ending at
08 Jun 1998 05:50:47 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" e-mail address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 1998 Greg Bacon. All Rights Reserved.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Excluded Posters
================
perlfaq-suggestions\@mox\.perl\.com
Totals
======
Posters: 497
Articles: 1392 (563 with cutlined signatures)
Threads: 418
Volume generated: 2287.1 kb
- headers: 943.2 kb (19,319 lines)
- bodies: 1255.5 kb (39,756 lines)
- original: 863.2 kb (29,434 lines)
- signatures: 87.0 kb (1,849 lines)
Original Content Rating: 0.688
Averages
========
Posts per poster: 2.8
median: 1 post
mode: 1 post - 329 posters
s: 7.5 posts
Posts per thread: 3.3
median: 2.0 posts
mode: 1 post - 122 threads
s: 4.7 posts
Message size: 1682.4 bytes
- header: 693.9 bytes (13.9 lines)
- body: 923.6 bytes (28.6 lines)
- original: 635.0 bytes (21.1 lines)
- signature: 64.0 bytes (1.3 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
76 141.4 ( 59.7/ 73.2/ 59.9) tchrist@mox.perl.com (Tom Christiansen)
72 110.1 ( 45.7/ 64.3/ 32.8) Gellyfish@btinternet.com (Jonathan Stowe)
66 109.9 ( 42.3/ 63.9/ 32.4) lr@hpl.hp.com (Larry Rosler)
64 96.8 ( 50.0/ 39.3/ 26.0) Tom Phoenix <rootbeer@teleport.com>
62 97.9 ( 45.4/ 52.4/ 31.3) jdporter@min.net
27 44.3 ( 17.9/ 20.8/ 14.3) mgjv@comdyn.com.au (Martien Verbruggen)
22 33.1 ( 14.6/ 18.4/ 10.0) sowmaster@juicepigs.com (Bob Trieger)
21 31.4 ( 13.8/ 16.5/ 15.0) gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
17 25.0 ( 9.8/ 15.1/ 10.0) tadmc@flash.net (Tad McClellan)
17 30.0 ( 13.6/ 12.0/ 7.3) rjk@coos.dartmouth.edu (Ronald J Kimball)
These posters accounted for 31.9% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
141.4 ( 59.7/ 73.2/ 59.9) 76 tchrist@mox.perl.com (Tom Christiansen)
110.1 ( 45.7/ 64.3/ 32.8) 72 Gellyfish@btinternet.com (Jonathan Stowe)
109.9 ( 42.3/ 63.9/ 32.4) 66 lr@hpl.hp.com (Larry Rosler)
97.9 ( 45.4/ 52.4/ 31.3) 62 jdporter@min.net
96.8 ( 50.0/ 39.3/ 26.0) 64 Tom Phoenix <rootbeer@teleport.com>
44.3 ( 17.9/ 20.8/ 14.3) 27 mgjv@comdyn.com.au (Martien Verbruggen)
33.1 ( 14.6/ 18.4/ 10.0) 22 sowmaster@juicepigs.com (Bob Trieger)
33.1 ( 8.9/ 19.3/ 12.0) 16 mike@stok.co.uk (Mike Stok)
31.4 ( 13.8/ 16.5/ 15.0) 21 gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
30.2 ( 13.4/ 14.7/ 6.2) 15 abigail@fnx.com
These posters accounted for 31.8% of the total volume.
Top 10 Posters by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.982 ( 6.8 / 6.9) 12 pudge@pobox.com (Chris Nandor)
0.963 ( 3.3 / 3.5) 6 fl_aggie@thepentagon.com (I R A Aggie)
0.905 ( 15.0 / 16.5) 21 gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
0.896 ( 2.2 / 2.4) 10 perlguy@technologist.com
0.885 ( 9.5 / 10.7) 6 scott@softbase.com
0.875 ( 15.9 / 18.2) 16 mjd@op.net (Mark-Jason Dominus)
0.819 ( 59.9 / 73.2) 76 tchrist@mox.perl.com (Tom Christiansen)
0.802 ( 6.1 / 7.6) 6 "Allan M. Due" <due@murray.fordham.edu>
0.750 ( 6.7 / 8.9) 10 cberry@cinenet.net (Craig Berry)
0.744 ( 4.0 / 5.4) 5 "Gary M. Greenberg" <garyg@gator.net>
Bottom 10 Posters by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.479 ( 3.7 / 7.7) 10 Peter A Fein <p-fein@uchicago.edu>
0.475 ( 1.3 / 2.8) 5 arch@abts.net
0.470 ( 2.9 / 6.1) 11 kpreid@ibm.net (Kevin Reid)
0.470 ( 2.7 / 5.8) 5 ilya@math.ohio-state.edu (Ilya Zakharevich)
0.429 ( 5.6 / 13.1) 13 bowlin@sirius.com
0.423 ( 6.2 / 14.7) 15 abigail@fnx.com
0.402 ( 3.2 / 7.9) 8 David Cross-cmt <Dave.Cross@gb.swissbank.com>
0.386 ( 5.9 / 15.3) 16 Ala Qumsieh <aqumsieh@matrox.com>
0.337 ( 2.3 / 6.9) 10 REUBEN LOGSDON <rlogsdon@io.com>
0.317 ( 0.9 / 3.0) 5 dlynch@morrisonscientific.com
Top 10 Threads by Number of Posts
=================================
Posts Subject
----- -------
49 map in void context regarded as evil - suggestion
38 Why is there no "in" operator in Perl?
27 Use of HTML, POD, etc in Usenet (was: Re: map in void context regarded as evil - suggestion)
24 decimal arithmetic
21 Foreach Efficiency
17 Is PERL case sensitive?
17 -d ? 3 : 7 is ambiguous, how comes?
15 I'm having problems:
12 Spider programms in PERL
11 newbie: trying to remove unwanted data from an array....
These threads accounted for 16.6% of all articles.
Top 10 Threads by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Subject
-------------------------- ----- -------
81.5 ( 39.4/ 36.3/ 22.5) 49 map in void context regarded as evil - suggestion
64.8 ( 27.7/ 32.8/ 22.9) 38 Why is there no "in" operator in Perl?
52.9 ( 28.6/ 21.6/ 12.6) 27 Use of HTML, POD, etc in Usenet (was: Re: map in void context regarded as evil - suggestion)
44.3 ( 16.5/ 25.2/ 17.7) 24 decimal arithmetic
36.7 ( 14.4/ 19.9/ 11.1) 21 Foreach Efficiency
28.6 ( 13.4/ 13.7/ 8.0) 17 -d ? 3 : 7 is ambiguous, how comes?
24.6 ( 12.1/ 11.2/ 6.7) 17 Is PERL case sensitive?
24.2 ( 10.9/ 12.1/ 7.3) 15 I'm having problems:
22.5 ( 6.1/ 15.7/ 10.0) 9 Sorting a Perl hash of complex records...
22.1 ( 6.5/ 14.3/ 12.0) 9 Am I looking at an anonymous array
These threads accounted for 17.6% of the total volume.
Top 10 Threads by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.875 ( 4.6/ 5.3) 5 Determining JPEG and GIF dimension sizes in PERL
0.850 ( 7.7/ 9.0) 5 what's a cross-platform \n please?
0.839 ( 6.9/ 8.3) 5 novice question: improving this code?
0.837 ( 12.0/ 14.3) 9 Am I looking at an anonymous array
0.815 ( 5.0/ 6.2) 5 Specialized Split
0.809 ( 5.4/ 6.7) 6 Q: dispatch find/replace string
0.801 ( 3.6/ 4.5) 7 Regular Expressions
0.790 ( 4.8/ 6.1) 6 study;
0.786 ( 1.9/ 2.5) 5 A problem with [\d]+
0.778 ( 3.9/ 5.0) 5 regexp: Validating UPC Code
Bottom 10 Threads by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.542 ( 3.0 / 5.5) 5 User System Info.
0.535 ( 6.1 / 11.3) 11 newbie: trying to remove unwanted data from an array....
0.533 ( 4.5 / 8.5) 7 Taking data out of strings
0.529 ( 3.5 / 6.5) 6 perl cgi generated html with java app dont run
0.521 ( 4.2 / 8.1) 5 Regex: parens inside quantifiers: can you capture all of them?
0.487 ( 2.7 / 5.5) 6 Help!!!! "ccperl -e" behaves differently under UNIX and Windows 95
0.453 ( 3.3 / 7.3) 7 lines of text, inserting spaces
0.437 ( 1.8 / 4.1) 9 Removing a character from a string
0.374 ( 4.7 / 12.6) 6 HTTP Header Info
0.334 ( 1.1 / 3.3) 5 Can I email with attachements
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
21 comp.lang.perl.modules
16 comp.lang.perl
10 de.comp.lang.perl
9 comp.lang.javascript
9 misc.comp.lang.mopdules
8 comp.lang.perl.misc
6 alt.perl
6 gnu.misc.discuss
5 no.it.programmering.perl
5 no.perl
Top 10 Crossposters
===================
Articles Address
-------- -------
14 lr@hpl.hp.com (Larry Rosler)
9 David Wasserstrum <zeos@gti.com>
8 hex@voicenet.com (Matt Knecht)
6 ehood@geneva.acs.uci.edu (Earl Hood)
5 panda@mis.net (Jason Stephenson)
5 suave@colba.net
5 Gellyfish@btinternet.com (Jonathan Stowe)
5 "Ryan G." <rdg2@axe.humboldt.edu>
5 waulok (at)
4 Andy Chantrill <support@derby-county.com>
------------------------------
Date: Mon, 08 Jun 1998 15:26:55 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: substitution not working
Message-Id: <linberg-0806981526550001@projdirc.literacy.upenn.edu>
In article <357C2E74.645428E6@cat.com>, "Vincent M. Probasco"
<probavm@cat.com> wrote:
> Alright, I know this is an easy one. Forgive me, but I've been looking
> at this one for awhile. Yes,
> I've checked the manual and the FAQs. Maybe I'm just missing something
> but why isn't this
> code working ?
>
> $osee = "<See?>";
> $sub = "<person><TD>".$form_data{'signy'}."</TD><See?>";
> $line =~ s/$osee/$sub/;
Well, I spent all of three seconds contemplating this, but you want to be
careful to properly escape strings you'll be using in regular expressions,
right? Your question mark in $osee is just begging to be misinterpreted.
And are you sure $line has what you think it has?
------------------------------
Date: Mon, 08 Jun 1998 19:47:07 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: what's a cross-platform \n please?
Message-Id: <6lhf6o$q3p$1@cyprus.atlantic.net>
According to "Alan J. Flavell" <flavell@mail.cern.ch>:
>Despite hunting through the FAQs etc. I'm still confused about precisely
>what a \n represents.
OK, here's the deal.
"\n" is a byte. Which byte it is depends on your C compiler. The
only guarantee you have is that from the point of view of a user
(i.e. you), each line of a text file will appear to end with "\n".
That works because the C library automatically translates (if
necessary) the native line ending to the byte "\n" and vice versa.
Thus, when you print(HANDLE "\n"), you may or may not actually be
writing just one byte to the given file. It depends on the
translation your C library is doing on your behalf.
Note that the binmode() operator may have some bearing on whether
that translation happens or not for a given filehandle.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"I brought the atom bomb. I think it's a good time to use it." //MST3K
-> Ask me about Perl training and consulting <-
Like Perl? Want to help out? The Perl Institute: www.perl.org
------------------------------
Date: 8 Jun 1998 20:24:17 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <6lhh9h$gn$1@supernews.com>
Nothing above this line is part of the signed message.
In article <6lh89c$9ga$1@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>Snowhare (snowhare@xmission.xmission.com) wrote on MDCCXLII September
>MCMXCIII in <URL: news:6lh3sd$6d4$1@xmission.xmission.com>:
>++ In article <6lgsuk$5k7$1@client3.news.psi.net>,
>++ Abigail <abigail@fnx.com> wrote:
>++ >
>++ >Building? What's the build when the array is given?
>++
>++ Naughty naughty. If you get to assume that your array is 'given' then I
>++ get to assume my hash is 'given' as well. Then the comparision becomes
>++ S O(N) vs T and the hash wins _all_ the time for large enough N. Data
>++ structures do not come from nowhere.
>
>This thread started with the question:
>
> Am I missing something or does Perl lack the ability to check if
> something is part of a list,
> <3576f315.106536561@news.mindspring.com>
>
>That looks to me the list is already there, but the hash isn't.
That doesn't mean you get to neglect the construction time.
The 'list' (and there is a certain amount of semantic ambiguity
in this context as to whether the author strictly meant a
array) had to be built. If you were going to assemble a
set of elements - you would put them into the most efficient
structure available for what you intend to use it for. Since
we _don't know_ the entire intended usage, there is no reason
to assume that it _must_ be an array vice a hash initially.
I could just as validly claim that his 'list' is originally
a hash and you now have to copy its keys into an array.
But that isn't a fair test because then I would be factoring
out the creation time for the hash while forcing you to include
it for the array.
[...]
>As for array lookups, yes they require in general a multiplication.
>But how do you think hash keys and values are stored?
Point.
>++ My _instinct_ says that _most_ of the time, for a single search, with
>++ perfectly optimized array search and hash functions and short variable
>++ strings, the array search will win for a single search.
>
>Which is what I was claiming.
Note the qualification: 'My _instinct_'. That says that I suspect
its truth but haven't proved it. This is a red flag for something
that should be investigated further.
[...]
>++ swallowed by it) or degenerate cases like lists of identically sized
>++ 200000 character strings differing only in their final 10 positions.
>
>
>And don't forget the phases of the moon!
>
>
>#!/usr/local/bin/perl -w
>
>use strict;
>use Benchmark;
>
>my @array = map {my $str = '';
> foreach (1 .. 2 + int rand (5) + int rand (5)) {
> $str .= chr (int rand 256);
> }
> $str} 1 .. 5000;
>
>my $q = '';
>foreach (1 .. 2 + int rand (5) + int rand (5)) {$q .= chr (int rand 256);}
>
>
>timethese 1000, {
> 'in' => sub {foreach (@array) {return 1 if $_ eq $q}},
> 'hash' => sub {my %hash; @hash {@array} = (); exists $hash {$q} ? 1 : 0}
>};
>
>__END__
>Benchmark: timing 1000 iterations of hash, in...
> hash: 103 secs (84.21 usr 0.18 sys = 84.39 cpu)
> in: 49 secs (38.49 usr 0.07 sys = 38.56 cpu)
Bad benchmark. Its performance will vary _a lot_ from run to
run because $q is not reassigned during each test. So you could pick
a value that during one run would finish on $array[0] (*REALLY*
fast) and the next run could pick a value that would finish on
$array[$#array] (*REALLY* slow) for all 1000 iterations.
You should have chosen the value at the mid-point of the array to
get the average case. And you compared apples and oranges by making
the hash get rebuilt everytime while factoring the array build out of
the loop.
Here is an improved one that demonstrates just how much difference
factoring out the builds makes (as well as demonstrates the
importance of picking the right implementation and benchmark
methodology to prevent comparing apples and oranges):
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my @array = map {my $str = '';
foreach (1 .. 2 + int rand (5) + int rand (5)) {
$str .= chr (int rand 256);
}
$str} 1 .. 5000;
my ($q) = $array[2500];
my (%hash);
@hash{@array} = ();
timethese 1000, {
'in2' => sub {grep($q eq $_,@array) ? 1 : 0},
'hash2' => sub {exists $hash {$q} ? 1 : 0},
'in1' => sub {my @newarray; @newarray = @array; grep($q eq $_,@newarray) ? 1 : 0 },
'hash1' => sub {my %newhash; @newhash {@array} = (); exists ($newhash {$q}) ? 1 : 0},
'in0' => sub {my @newarray; @newarray = @array; foreach (@newarray) {return 1 if $_ eq $q}},
'hash0' => sub {my %newhash; @newhash {@array} = (); exists $newhash {$q} ? 1 : 0},
'in' => sub {foreach (@array) {return 1 if $_ eq $q}},
'hash' => sub {my %newhash; @newhash {@array} = (); exists $newhash {$q} ? 1 : 0}
};
__END__
Benchmark: timing 1000 iterations of hash, hash0, hash1, hash2, in, in0, in1, in2...
hash: 42 secs (40.78 usr 0.01 sys = 40.79 cpu)
hash0: 42 secs (40.77 usr 0.04 sys = 40.81 cpu)
hash1: 41 secs (40.56 usr 0.01 sys = 40.57 cpu)
hash2: 0 secs ( 0.02 usr 0.00 sys = 0.02 cpu)
(warning: too few iterations for a reliable count)
in: 7 secs ( 7.08 usr 0.00 sys = 7.08 cpu)
in0: 42 secs (40.88 usr 0.04 sys = 40.92 cpu)
in1: 45 secs (44.73 usr 0.02 sys = 44.75 cpu)
in2: 11 secs (11.29 usr 0.00 sys = 11.29 cpu)
The build times actually *favor* the hash over the array
- slightly - and the build time appears to take MORE time
than the search itself does by a large factor: Thus my original
concern about neglecting the build time when considering the
performance of a single search was justified. It appears that,
on average, it *IS* faster (just barely), even for just one search,
to build the hash and lookup the result than to build the array and
search it.
It seems the phase of the moon doesn't favor arrays today.
Benjamin Franz
"Damn it. Do you realize I had to upgrade my Perl from 5.003 to run
these benchmarks? ;-)"
Version: 2.6.2
iQCVAwUBNXxN3ujpikN3V52xAQGonQP+Ip7ZRWTbnGp3DBCEtgkfz4i/Y6q1sqxC
qh8XiLar7dWxpEtyDqJk1VgCVQgNOKF9iTD7kqaYK1DUoK3q7Z9yaG7nKOpvF3fJ
twehMm1ZS37lmDVdWybjKs/Bpz2Tge9PcHdyyV1PqG5/xjcmjSFgMuUkoIgSumCF
bv3FHzOKdeM=
=K8oP
-----END PGP SIGNATURE-----
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
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 2815
**************************************