develooper Front page | perl.beginners | Postings from April 2002

Re: assigning array to hash

Thread Previous | Thread Next
From:
Chas Owens
Date:
April 29, 2002 22:29
Subject:
Re: assigning array to hash
Message ID:
1020144168.2722.174.camel@tert.icallinc.com
On Tue, 2002-04-30 at 00:22, drieux wrote:
> 
> On Monday, April 29, 2002, at 08:29 , Chas Owens wrote:
> 
> >
> > TMTOWTDI:
> >
> > my @array = qw(first second last);
> > my %hash;
> > #the $" var controls what characters separate elements of
> > #an interpolated array
> > { local $" = '|'; $hash{somekey} = "@array"; }
> 
> can You get Your Brilliant Flashes in Gear....
> 
> remember that you need to remind folks that this deconstructs with:
> 
> 	my @chas_array =  split(/\|/, $hash{$chas});
> 
> updated:
> 
> http://www.wetware.com/drieux/CS/lang/Perl/Beginners/BenchMarks/loopVjoin.
> txt
> 
> actually it's in the contenders list....

It should be nearly identical to the straight join since this code:

$hash{key} = "@array";

is turned into this code

$hash{key} = join $", @array;

by the compiler.

> 
> Geez Chas, If you're Gonna Whine - whould you get there on time:
> Benchmark: timing 50000 iterations of aref, chasNeff, j2ref, join, join2, 
> jref, loop, loop3...
>    chasNeff: 56 wallclock secs (51.34 usr +  0.00 sys = 51.34 CPU) @ 973.90/
> s (n=50000)
>        join: 55 wallclock secs (49.95 usr +  0.00 sys = 49.95 CPU) @ 
> 1001.00/s (n=50000)
>       join2: 55 wallclock secs (51.08 usr +  0.00 sys = 51.08 CPU) @ 978.86/
> s (n=50000)
>        jref: 35 wallclock secs (31.69 usr +  0.00 sys = 31.69 CPU) @ 
> 1577.78/s (n=50000)
> 
> ......
> 
> ciao
> drieux
> 
> ---
> 
> Come on Chas - what is it, some outside experience,
> some hot date that takes precedence over Perl.....

Sleep dep + compiling Linux from scratch on my laptop while
simultaneously working on production problems and posting fscked up
comments to this list and the Gtk Perl list. 

> 
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> 
> 
-- 
Today is Setting Orange the 47th day of Discord in the YOLD 3168


Missile Address: 33:48:3.521N  84:23:34.786W


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About