in reply to how can i replace a hash key with other hash value?
You can't "replace a key" but you can set a new one and delete the existing oneuse strict; use warnings; my %hash=("one" =>1, "two"=>,2); my %hash_tr_fr=(one=>"une","two"=>"deux"); for my $eng (keys %hash){ $hash{$hash_tr_fr{$eng}}=$hash{$eng}; delete $hash{$eng}; } use Data::Dumper; print Dumper(\%hash);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how can i replace a hash key with other hash value?
by JavaFan (Canon) on Mar 24, 2010 at 10:39 UTC | |
by cdarke (Prior) on Mar 24, 2010 at 10:59 UTC |