Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: unknown number of dimensions of a multidimensional hash

by Anonymous Monk
on Mar 10, 2006 at 00:47 UTC ( #535575=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: unknown number of dimensions of a multidimensional hash
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://535575]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2015-07-06 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (72 votes), past polls