Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003203]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2016-12-08 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (133 votes). Check out past polls.