in reply to Re^4: setting PERL_PERTURB_KEYS & PERL_HASH_SEED in a perl file
in thread setting PERL_PERTURB_KEYS & PERL_HASH_SEED in a perl file
Hi,
Lets say we have this hash:
$hash{a} = 0; $hash{b} = 1; $hash{c} = 0; $hash{d} = 3;
The expected output is:
a = 0 c = 0 b = 1 d = 3
or
c = 0 a = 0 b = 1 d = 3
(note how 'a' & 'c' are switched)
Both are correct!
However, for consistency, I rather have always the same output.
The code that I'm using is:
foreach my $k ( sort { $hash{$a} <=> $hash{$b} } keys %hash ) { print "$k = $hash{$k}\n"; }
Thx
Guy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: setting PERL_PERTURB_KEYS & PERL_HASH_SEED in a perl file (sort)
by tye (Sage) on Jul 18, 2016 at 13:20 UTC | |
|
Re^6: setting PERL_PERTURB_KEYS & PERL_HASH_SEED in a perl file
by haukex (Archbishop) on Jul 18, 2016 at 13:21 UTC | |
by gravid (Novice) on Jul 18, 2016 at 13:31 UTC |