Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^7: keys and values order on a hash

by BrowserUk (Patriarch)
on Jul 11, 2011 at 20:11 UTC ( [id://913766] : note . print w/replies, xml ) Need Help??


in reply to Re^6: keys and values order on a hash
in thread keys and values order on a hash

Then please, implement a benchmark that exhibits the savings you are concerned about.

#! perl -slw use strict; use Benchmark qw[ cmpthese ]; our %hash = 'aaaaa' .. 'dzzzz'; cmpthese 1, { a => q[ my @keys = keys %hash; my @vals = values %hash; my $x; $x = "$keys[ $_ ] :: $vals[ $_ ]" for 0 .. $#keys; ], b => q[ my( $k, $v, $x ); $x = "$k :: $v" while ( $k, $v ) = each %hash; ] }; __END__ s/iter a b a 3.06 -- -41% b 1.79 70% --

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.