in reply to How to print an array of multidimensional arrays with a for or foreach loop

Have a look at the ref function:

foreach $row (@array) { foreach $column (ref $row ? @$row : $row) { print "This is the \$column: ".$column."\n"; } }

This assumes that if something is a reference, it's an array reference. If $row can also contain hash references or other data, you'll have to look at the return value of ref.

Also there's CPAN modules, although I haven't used them myself I've sometimes seen them recommended: Data::Walk, Data::Diver, Data::Visitor, Data::Path

Replies are listed 'Best First'.
Re^2: How to print an array of multidimensional arrays with a for or foreach loop
by thanos1983 (Parson) on Aug 11, 2014 at 01:25 UTC

    Hello Anonymous Monk,

    So many useful modules, I usually use Data::Dumper but is always nice to learn new things.

    My answer was simple but some times when the user dose not have the knowledge can become so complicated.

    Thank you for your time and effort, reading and replying to my question.

    Seeking for Perl wisdom...on the process of learning...not there...yet!