in reply to Re^2: Bulk hash population order
in thread Bulk hash population order
We know that the perl interpreter will parse this equivalently to:
However, the kinds of assumptions you are making have been made by many folks for years, and it's this kind of assumption that can stymy any interesting optimizations that the interpreter could do with bulk insertions.my @hiddenlist = ( 'A', 1, 'A', 2, 'A', 3 ); my %lilhash; while (@hiddenlist) { my $hiddenkey = shift @hiddenlist; $lilhash{$hiddenkey} = shift @hiddenlist; } print $lilhash{'A'};
I just think it's a bad idea when the word "order" and the word "hash" come anywhere near each other to start making such assumptions. Regardless of how safe or well-entrenched the idiom may be, my advice is: the hash is unordered and the list is ordered and if you care about order, be explicit.
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Bulk hash population order
by Fletch (Bishop) on Nov 27, 2007 at 15:16 UTC |