in reply to Count number of words on a web page?
#!/usr/bin/perl $/ = ""; $* = 1; while (<>) { #s/-\n//g; tr/A-Z/a-z/; @words = split(/\W*\s+\W*/, $_); # split into words foreach $word (@words) { $wordcount{$word}++; # count the words } } foreach $word (sort keys(%wordcount)) { printf "%8d\t\t%s\n", $wordcount{$word}, $word; }
Hope that helps
Jeffery
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Count number of words on a web page?
by cdarke (Prior) on Feb 09, 2010 at 16:26 UTC | |
Re^2: Count number of words on a web page?
by jdlev (Scribe) on Feb 09, 2010 at 13:49 UTC |
In Section
Seekers of Perl Wisdom