PERL. size of Multi-dimensional array
Posted: Tue Mar 18, 2003 4:20 pm
In PERL: I am having difficulty finding the number of elements in the Nth dimension of an array. I can get the size of the base array, but anything deeper I am dying on.
Ex:
@arr;
$arr[0]="hello";
$arr[1]="goodbye";
$arr[0][0]="greetings";
$arr[0][1]="salutations";
$arr[0][2]="yo";
$arr[1][0]="see ya";
$arr[1][1]="adios";
$arr_len=scalar(@arr); # $arr_len = 2
What I am trying to do is find the number of elements in $arr[0] (should be 3), and $arr[j][k][etc.,].
I have read the Camel, and hunted on Google to no avail. Help?
Ex:
@arr;
$arr[0]="hello";
$arr[1]="goodbye";
$arr[0][0]="greetings";
$arr[0][1]="salutations";
$arr[0][2]="yo";
$arr[1][0]="see ya";
$arr[1][1]="adios";
$arr_len=scalar(@arr); # $arr_len = 2
What I am trying to do is find the number of elements in $arr[0] (should be 3), and $arr[j][k][etc.,].
I have read the Camel, and hunted on Google to no avail. Help?