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 |