in reply to
count words in a line
Even the last one is simpler than the others here would suggest. You can simply remove all whitespace first:
$line =~ s/\s+//g;
After that, you can count the occurences with any of the other methods proposed here.
Makeshifts last the longest.
Comment on
Re: count words in a line
Download
Code
In Section
Seekers of Perl Wisdom