Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: A little fun with hashes

by ehdonhon (Curate)
on Aug 16, 2002 at 22:00 UTC ( [id://190761]=note: print w/replies, xml ) Need Help??


in reply to A little fun with hashes

If you run this in a loop, you'll eventually get to a point where all the values are non-keys. But this solution assumes you are not interested in the recursion. It also assumes you want to process every key in the hash and not just "0".

my %newhash; foreach my $key ( keys( %hash ) ) { $newhash{$key} = [ map {exists($hash{$_}) ? $hash{$_} : $_;} (valu +es %hash) ]; } %hash = %newhash;

Log In?
Username:
Password:

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

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

    No recent polls found