Here is the code I have, but it doesn't seem to work:
#!/usr/bin/perl use warnings; use strict; my($count, $pattern); my $input = shift; $pattern = \b\w+\b; open(FILE,"$input") or die "Error: $!\n"; $count = 0; while(<FILE>) { if(/$pattern/) { $count++; } } print "Word Count = ", $count, "\n\n";
Any suggestions?
In reply to Counting words by raveguy2k
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |