pc0019 has asked for the wisdom of the Perl Monks concerning the following question:
my %hash = ( '.111' => 'Aaaa', '.222' => 'Bbbb', '.333' => 'Cccc' ); $hash{$_} = substr $hash{$_}, 2 for keys %hash;
But I have no idea how to do this for the keys. Ideal output is:
print Dumper \%hash; -- -- -- -- -- -- -- -- $VAR1 = { '33' => 'Cccc', '22' => 'Bbbb', '11' => 'Aaaa' };
Thanks in advance!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using substr on Hash Keys
by dwm042 (Priest) on Sep 10, 2008 at 19:17 UTC | |
|
Re: Using substr on Hash Keys
by kyle (Abbot) on Sep 10, 2008 at 19:47 UTC | |
by jettero (Monsignor) on Sep 10, 2008 at 19:53 UTC | |
by ikegami (Patriarch) on Sep 10, 2008 at 23:37 UTC | |
by jettero (Monsignor) on Sep 11, 2008 at 01:45 UTC | |
by jwkrahn (Abbot) on Sep 10, 2008 at 21:11 UTC | |
by ikegami (Patriarch) on Sep 10, 2008 at 23:38 UTC | |
by jwkrahn (Abbot) on Sep 11, 2008 at 01:13 UTC | |
| |
by pc0019 (Acolyte) on Sep 10, 2008 at 20:28 UTC | |
by GrandFather (Saint) on Sep 10, 2008 at 21:04 UTC | |
|
Re: Using substr on Hash Keys
by jettero (Monsignor) on Sep 10, 2008 at 19:03 UTC | |
by mr_mischief (Monsignor) on Sep 10, 2008 at 19:12 UTC | |
|
Re: Using substr on Hash Keys
by poolpi (Hermit) on Sep 11, 2008 at 09:56 UTC |