Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Length of array in hash of arrays

by gurpreetsingh13 (Scribe)
on May 13, 2013 at 05:29 UTC ( #1033248=note: print w/ replies, xml ) Need Help??


in reply to Re: Length of array in hash of arrays
in thread Length of array in hash of arrays

Like this:

$ perl -e 'my %g = (k => [8, 2, 10, 2, 1, 3],l => [10, 7, 9, 0, 1]); f +oreach $keyval(sort keys %g){print 0+@{$g{$keyval}};}'


Comment on Re^2: Length of array in hash of arrays
Download Code
Replies are listed 'Best First'.
Re^3: Length of array in hash of arrays
by ambrus (Abbot) on Oct 24, 2013 at 15:27 UTC

    That prints only the length of the first subarray, the one corresponding to the key "k". Let's do better and use the each keyword to print the length of each subarray.

    my %g = (k => [8, 2, 10, 2, 1, 3],l => [10, 7, 9, 0, 1]); %gkey = sort keys %g; print 0+@{$g{each %gkey}}, "\n";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2015-08-02 19:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (12 votes), past polls