I have no clue why anyone might need this. I created it while answering a question about multidimensional arrays. It is my first successful recursive sub.
sub depth { my $arr = shift; return 1 unless ref $$arr[0] eq 'ARRAY'; return depth( $$arr[0] ) + 1; }
Call it with a reference to your array of arrays structure
print depth( \@array );Update: Changed the fourth line to indicate the correct sub.
In reply to Depth of AoAs by CharlesClarkson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |