in reply to Hash problem - Perl noob
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]}++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash problem - Perl noob
by ikegami (Patriarch) on Sep 15, 2006 at 16:58 UTC | |
by tinita (Parson) on Sep 16, 2006 at 09:07 UTC | |
by ikegami (Patriarch) on Sep 16, 2006 at 09:28 UTC | |
by ptum (Priest) on Sep 15, 2006 at 17:25 UTC |