Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: can I change hash keys or values directly

by jwkrahn (Abbot)
on Jan 28, 2021 at 21:35 UTC ( [id://11127608]=note: print w/replies, xml ) Need Help??


in reply to can I change hash keys or values directly

$ perl -le'my %x = "A" .. "F"; print "@{[ %x ]}"; $_ = lc for %x; prin +t "@{[ %x ]}";' C D A B E F C d A b E f

So, no, you can't modify hash keys directly.

However, you can do this:

$ perl -le'my %x = "A" .. "F"; print "@{[ %x ]}"; $x{ lc() } = delete +$x{ $_ } for keys %x; print "@{[ %x ]}";' E F A B C D c D a B e F

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (8)
As of 2024-04-24 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found