in reply to Deterministic or keys in random order
All of these print "Zero" on my build of perl (5.8.7)
As a Perl programmer you should never write code which relies on the order returned by keys/each (apart from it being the same as the list time you checked, if you’ve not updated the array).my %hash = ( "Zero" =>"0", "One" => "1", "Two" => "2", ); my @array = keys %hash; print $array[0] . "\n"; -------------------------- my %hash = ( "One" => "1", "Zero" =>"0", "Two" => "2", ); my @array = keys %hash; print $array[0] . "\n"; -------------------------- my %hash = ( "Two" => "2", "One" => "1", "Zero" =>"0", ); my @array = keys %hash; print $array[0] . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Deterministic or keys in random order
by andreas1234567 (Vicar) on May 14, 2008 at 18:29 UTC |