in reply to the last added element of a hash
$h{'11c'} = 'C'; $h{'b'} = 'B'; $h{'e22'} = 'E'; $h{'aaaaa'} = 'AAAA'; for (keys %h){ $a = \$h{$_} and $b = $_ if $a < \$h{$_}; } print "$b\n"; { my $str = "bogus" x 10000; $h{foo} = 'F'; } $h{bar} = 'B'; for (keys %h){ $a = \$h{$_} and $b = $_ if $a < \$h{$_}; } print "$b\n";
I get "foo" like this and "bar" if I change the 10000 to 1000. The numbers may be different for you, but as soon as things happen between the additions, you are not guaranteed to get the last. Even just computing the values for the hash could cause changes to the result.
Jenda
Enoch was right!
Enjoy the last years of Rome.
|
|---|