Perl Monk, Perl Meditation | |
PerlMonks |
Re: can I change hash keys or values directlyby choroba (Cardinal) |
on Jan 28, 2021 at 21:34 UTC ( [id://11127607]=note: print w/replies, xml ) | Need Help?? |
There's no array of keys or values. There's a list of keys and list of values, and the list of values in fact contains the values themselves, so you can modify them, e.g.
You can't modify the keys in this way, though (and both the facts are documented in keys and values. That's because you can't change a key in a hash, you need to remove the old one and create a new one, because the after a key change, the value is most probably going to be stored in a different place. Using a slice is probably the best you can do. Be sure to keep the keys unique after the modification!
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In Section
Seekers of Perl Wisdom
|
|