ongaku has asked for the wisdom of the Perl Monks concerning the following question:
Here is a short program that shows that I can get to an array stored in a hash.
But how do I find out the length of said array?
# the program my %hash; my @arr; %hash = ( 'one' => [1], 'two' => [2,2], 'three' => [3,3,3], ); print "$hash{one}[0]\n"; print "$hash{two}[0]\n"; print "$hash{three}[0]\n"; $size = length $hash{one}; print ("size=$size\n"); $size = length $hash{two}; print ("size=$size\n"); print "all done\n"; % perl arrays.pl 1 2 3 size=16 size=16 all done
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: length or array in a hash
by SuicideJunkie (Vicar) on Nov 09, 2012 at 19:46 UTC | |
Re: length or array in a hash
by brap (Pilgrim) on Nov 09, 2012 at 19:45 UTC | |
Re: length or array in a hash
by 2teez (Vicar) on Nov 09, 2012 at 19:54 UTC | |
Re: length or array in a hash
by Cristoforo (Curate) on Nov 09, 2012 at 19:57 UTC | |
by karlgoethebier (Abbot) on Nov 10, 2012 at 16:39 UTC | |
by ongaku (Initiate) on Nov 14, 2012 at 19:26 UTC |
Back to
Seekers of Perl Wisdom