![]() |
|
Perl Monk, Perl Meditation | |
PerlMonks |
n3toy's scratchpadby n3toy (Hermit) |
on Aug 07, 2008 at 22:04 UTC ( #703013=scratchpad: print w/replies, xml ) | Need Help?? |
n3toy: I have a hash where the values are all numerical. Is there a quick way to sum all the hash values? GrandFather: my $total; $total += $_ for values %hash; Lawliet: $sum += $hash{$_} foreach keys %hash; tye: my $count= map( (1)x$_, values %hash ); Lawliet forgot there was a values keyword! davido: use List::Util qw(sum); my $total = sum( values %hash );
|
|