in reply to unknown number of dimensions of a multidimensional hash
If the hash is not ragged, you simply know its dimensionality. If you somehow lose this information
sub hashfirst { $_[0]->{($_) = keys %{$_[0]}} } sub shape { my $h = shift; my @s; for (;'HASH' ne ref $h; $h = hashfirst($h)) { push @s, scalar(keys %$h); } @s }
may help you remember. This feels like an X-Y question.
|
---|
In Section
Seekers of Perl Wisdom