How do I modify the split function to consider the punctuations as words?
He = 1 word.
said = 1 word
, = 1 word
" = 1 word
Well-done = 1 word
. = 1 word
" = 1 word
Contents of the test file:
He said, "Well-done."
#!/usr/bin/perl -w
open (FILE, "test.txt") or die "Error!";
my $words = 0;
while (<FILE>)
{
$words += scalar(split(/.+/));
}
print (" words = $words \n ");