Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Using substr on Hash Keys

by poolpi (Hermit)
on Sep 11, 2008 at 09:56 UTC ( [id://710566]=note: print w/replies, xml ) Need Help??


in reply to Using substr on Hash Keys

See Hash::Rename
Renaming hash's keys in place

#!/usr/bin/perl -w use strict; use Hash::Rename; my %h = ( '.111' => 'Aaaa', '.222' => 'Bbbb', '.333' => 'Cccc' ); hash_rename %h, code => sub { s/.{2}// }; __END__ Output: $VAR1 = { '22' => 'Bbbb', '11' => 'Aaaa', '33' => 'Cccc' };

hth,
PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://710566]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-23 07:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found