in reply to Hash problem - Perl noob
for my $elem (@phrase) { $wordfreq{$elem}++; }
# or even shorter, but perhaps a bit unreadable: $wordfreq{$_} for (@phrase);
When printing out the results you might want to print out the name of what you found, for example:$wordfreq{$_}++ for (@phrase);
Hope this was the answer you were looking for. Cheers Rolandforeach my $key (sort keys %wordfreq) { print "$key: $wordfreq{$key}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash problem - Perl noob
by chargrill (Parson) on Sep 15, 2006 at 18:01 UTC |