my @dims = (); my $thing = \@array; while (ref $thing eq "ARRAY") { push @dims, scalar @$thing; $thing = $thing->[0]; } print "@dims\n";