Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How do I convert entire hash to lowercase?

by japhy (Canon)
on Nov 18, 2001 at 11:50 UTC ( [id://126102]=note: print w/replies, xml ) Need Help??


in reply to How do I convert entire hash to lowercase?

(Updated.) I'd do this:
@hash{map lc, @k} = map lc, delete @hash{@k = keys %hash};
Nifty?

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: How do I convert entire hash to lowercase?
by data64 (Chaplain) on Nov 18, 2001 at 21:49 UTC
    I don't think I completely understand how exactly this piece of code works.
    Can someone explain ?

    thanks.
      I think I can...
      # @hash{map lc, @k} = # map lc, delete @hash{@k = keys %hash}; @keys = keys %hash; @lc_values = map { lc $_ } @hash{@keys}; # hash slice @lc_keys = map { lc $_ } @keys; delete @hash{@keys}; # basically: %hash = () @hash{@lc_keys} = @lc_values;
      </code>

      _____________________________________________________
      Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found