so...this is suposed to count the words in FILE and return how many occourances of
each word there were...its not working for me though....its only returning the count
for the last word in the file...help
#!/usr/local/bin/perl
open (FILE,"../www/main.php3");
@lines=<FILE>;
close(FILE);
foreach $i (@lines) {
@words = split(/\s+/, $i);
}
foreach $word (@words) {
$wordcount{"$word"}=0;
}
foreach $word2 (@words) {
$wordcount{"$word2"}+=1;
}
foreach $key (keys (%wordcount)) {
print "$wordcount{$key} occourances of the whord $key\n";
}