Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: can I change hash keys or values directly

by choroba (Cardinal)
on Jan 28, 2021 at 21:34 UTC ( [id://11127607]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    use warnings;
    ...
    my %hash = (key1 => 'val1', key2 => 'val2');
    s/val/V/ for values %hash;
    say "$_ => $hash{$_}" for keys %hash;
    
  2. or download this
    my @old = keys %hash;
    @hash{map uc, @old} = delete @hash{@old};
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-26 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found