in reply to Re^3: Weighted frequency of characters in an array of strings
in thread Weighted frequency of characters in an array of strings
The chop version is wrong, it's trimming chars from the end, but counting them from zero. This fixes that:
for( @data ) { ## use $_ to alias the +lines my $p = length(); ## Allow pre-decrement +and count backwards $freq{ chop() }[ --$p ] += $inc while $p; ## implicit arg for cho +p; avoid call to length. }
|
---|