Change the first while to a foreach and remove the angle brackets from around @source and it'll work.
#!/usr/bin/perl -w use strict; open (SOURCE, '<', 'test.txt') || die "Can't open test.txt: $!"; my @source = <SOURCE>; close (SOURCE); my $size=0; foreach(@source){ $size++ while m{\b\w+\b}g; } print "wordcount: $size words\n";
In reply to Re: word boundary match problem
by Mr. Muskrat
in thread word boundary match problem
by martymart
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |