my $rh_count = { } ; while ( <DATA> ) { my ( $string, $count ) = split; $rh_count->{$string} += $count; } print "$_: $rh_count->{$_}\n" for keys %$rh_count; __DATA__ string1 10 string2 30 string1 0 string4 39 string9 345
In reply to Re: using hashes to count
by FunkyMonk
in thread using hashes to count
by spiros
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |