Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Hash with three keys

by hdb (Monsignor)
on Dec 12, 2013 at 21:46 UTC ( #1066926=note: print w/replies, xml ) Need Help??


in reply to Hash with three keys

Recursion is another solution to this, especially if you do not know upfront how deep your hashes are nested or if the depth is not the same everywhere:

use strict; use warnings; sub loop_over_hash { my( $keys, $href ) = @_; print join( ',', @$keys , $href ), "\n" and return unless 'HASH' e +q ref $href; loop_over_hash( [ @$keys, $_ ], $href->{$_} ) for keys %$href; } my %hash = ( a => { 1 => { x => 5, y => 6 }, 2 => { s => 7, t => 8 } }, b => { 3 => 'end', }, ); loop_over_hash [], \%hash;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2022-01-20 22:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (57 votes). Check out past polls.

    Notices?