Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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}},$/; }
Output
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2014-08-21 19:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (143 votes), past polls