"Mr. Shawn H. Corey" schreef:

> my $count = () = $lineFromFile =~ m/\b\w+\b/;

The "/g" modfier is missing.

Do you have a special reason to use \b next to \w?
I think it will work equally well without the \b-s.

The \w is "digits plus letters plus underscore", which in ASCII is
limited to [0-9A-Za-z_].

This means that "abc_def" is counted as 1 word, and "abc-def" as 2
words.
Use /[[:alnum:]]+/ if you want both counted as 2 words.

"O'Hara" is counted as 2, and "At Jones's." as 3 words, unless you use
/[[:alnum:]']+/

Etc.

-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to