raveguy2k has asked for the wisdom of the Perl Monks concerning the following question:
#!/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";
I get a backslash error on the line where I assign the pattern and it doesn't match any words. Would this find all the number of times there is a pattern with one or more characters in it surrounded by a boundry?
Thanks for the help -Brandon
Originally posted as a Categorized Question.
|
|---|