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

Re: Dynamically create a foreach loop within a foreach loop?

by AnomalousMonk (Archbishop)
on Dec 11, 2013 at 10:58 UTC ( [id://1066597]=note: print w/replies, xml ) Need Help??


in reply to Dynamically create a foreach loop within a foreach loop?

Take a look at Data::Dumper or Data::Dump (and many others of similar nature). Both of these modules define functions that iterate through arbitrarily deeply nested data structures — and they don't even require that they be purely hashes-of-hashes or arrays-of-arrays!

>perl -wMstrict -le "my %ds = ( X => [ { one => 1 }, { two => 2, three => 3 }, ], Y => [ { fee => 'fie' }, { foe => 'fum' }, { foo => 'bar' }, ], ); ;; use Data::Dumper; print Dumper \%ds; " $VAR1 = { 'X' => [ { 'one' => 1 }, { 'three' => 3, 'two' => 2 } ], 'Y' => [ { 'fee' => 'fie' }, { 'foe' => 'fum' }, { 'foo' => 'bar' } ] };

Replies are listed 'Best First'.
Re^2: Dynamically create a foreach loop within a foreach loop?
by choroba (Cardinal) on Dec 11, 2013 at 11:00 UTC
    wrong parent, reap

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-24 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found