in reply to Re^2: Function for reading file
in thread Function for reading file
... the word regex \W ...
It's important to understand what you're dealing with. The \W (that's big-W) character class (see perlrecharclass) matches any character that is not a \w (little-w) character. The \w characters are sometimes called "word" characters, but IIRC they originate with the set of characters that are allowed in a C- or Perl-language identifier; that's why _ (underscore) is included, but - (hyphen), for instance, is not. So \W is better described as the anti-word regex!
And I agree with davido's point here that if [A-Za-z\W] really does the trick for you, then [^_\d] is more clear, readable, maintainable, and IMHO preferable.
Update: Made "identifier" into a Wikipedia link.
Give a man a fish: <%-{-{-{-<
|
|---|