in reply to Character class question

perl -v will show the version of Perl you are running.

As for your regexp question, you are missing a backslash (\) before the letter "W". So, the propper line would be

} elsif (/[\W_]/) { # other chars
That would match anything that is not a number (0-9) or a character - but the characters a-z are captured by the if higher up in the code. (Note that this will have problems if input contains Unicode characters)...

Replies are listed 'Best First'.
Re:^2 Character class question
by bluethundr (Pilgrim) on Apr 25, 2004 at 21:17 UTC
    Thanks, to you and the dudes above sharing their wisdom! perl -v yielded 5.8.0. The info page said it was for 5.6.1. Now that I know this simple trick, I'll be able to be more accurate in my titles.

    As to the code, yup. I'm missing the backslash before the 'W'. Hopefully I'll become more adept at catching these errors as time goes on and my experience builds.THANKS again for the code advice and the posting advice to ALL!

      OK, now that we know what version you're running, go ahead and add these things at the top of your programs for the time being:

      use strict; # Helps to prevent a few common coding + # "mistakes" use warnings; # Turns on "lexically-scoped" warnings, # a bit better than -w use diagnostics; # Makes error messages more helpful

      If I had known about Diagnostics from the beginning, I would have saved myself so much work... ;)

      Update: Fixed improper capitalization as pointed out by the nice AM.

      --
      Damon Allen Davison
      http://www.allolex.net

        The proper invocation is use diagnostics;. With the capital D, it will fail to find the module on case-sensitive filesystems. On case-insensitive filesystems, where diagnostics.pm is the same file as Diagnostics.pm, you will not get an error loading the module, but the import method that enables diagnostics won't be called (because Diagnostics->import is called instead, which doesn't exist.)