in reply to Swapping keys and values in a hash with slices
But nobody promised you that keys and values would return in the same order though ;-)
Update:use Data::Dump qw( dump ); my %hash = ( 1 => "Piker", 2 => "Vin", 3 => "Sang" ); my %revhash; $revhash{$hash{$_}} = $_ for (keys(%hash)); print dump( \%hash ), "\n"; print dump( \%revhash ), "\n";
Forget about this, just use reverse as tomhukins said below.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Swapping keys and values in a hash with slices
by revdiablo (Prior) on Oct 20, 2004 at 17:57 UTC |