You seem to be stepping through the contents of @phrase with an i-based for loop, yet you're referring to the jth element in @phrase. You need to make up your mind ... are you iterating through @phrase with i or with j?
I think either of these (untested) would do what you want:
foreach (@phrase) { $wordfreq{$_}++; }
or this:
for (my $i=0;$i<=$#phrase;$i++) { $wordfreq{$phrase[$i]}++; }
In reply to Re: Hash problem - Perl noob
by ptum
in thread Hash problem - Perl noob
by UncleTom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |