Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: looping over multidimensional arrays

by LanX (Archbishop)
on Sep 20, 2018 at 14:35 UTC ( #1222718=note: print w/replies, xml ) Need Help??


in reply to looping over multidimensional arrays

for my $a1 (@x) { for my $a2 (@$a1) { for my $a3 (@$a2) { ... # hope you get the pattern by now } } }

For covering arbitrary depth of nesting you could apply a recursive function (a so called "walker")

If the elements are other than array_refs you might want to add cases after testing ref $aX.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2019-07-17 03:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?