Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Two questions about hashes

by SimonClinch (Chaplain)
on May 31, 2011 at 09:32 UTC ( #907429=note: print w/ replies, xml ) Need Help??


in reply to Two questions about hashes

I'd do something like:

Traverse( \%hashofsomethings, sub { warn "example $_[0]"; }); sub Traverse { my $node = shift; my $code = shift; local $_; if (ref( $node ) eq 'HASH' ) { Traverse( $_ ) for values %$node; } elsif(ref($node) eq 'ARRAY') { Traverse( $_ ) for @$node; } else{ $code ->( $node ); } }

One world, one people


Comment on Re: Two questions about hashes
Download Code
Replies are listed 'Best First'.
Re^2: Two questions about hashes
by Anonymous Monk on May 31, 2011 at 13:17 UTC
    Simon, You should create your BATX letters instead of ...
      What does mean BATX letters ? Is it a joke?
      I didn't understand it ...
Re^2: Two questions about hashes
by i5513 (Pilgrim) on Jun 02, 2011 at 20:13 UTC
    I need previous keys to know what is I'm computing, so this is not a good solution, but yes a good way learning recursion algorithms & perl ;)
    Thank you!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2015-07-29 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls