Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: length or array in a hash

by 2teez (Priest)
on Nov 09, 2012 at 19:54 UTC ( #1003203=note: print w/ replies, xml ) Need Help??

in reply to length or array in a hash

Hi, ongaku,
You can do like so:

%hash = ( 'one' => [1], 'two' => [2,2], 'three' => [3,3,3], ); foreach my $array (keys %hash){ print $array," :", scalar @{$hash{$array}},$/; }
three :3 one :1 two :2
You might want to check the function scalar

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Comment on Re: length or array in a hash
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-11-29 15:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (751 votes), past polls