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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Depth of AoAs
by rob_au (Abbot) on Jan 14, 2002 at 10:33 UTC | |
Re: Depth of AoAs
by merlyn (Sage) on Jan 15, 2002 at 02:50 UTC |
Back to
Cool Uses for Perl