http://www.perlmonks.org?node_id=1064299


in reply to Testing for valid package names

Roughly 10% of the 4000+ .pm files installed on my system have an underscore in the name, so I guess it's not that uncommon. (Find installed Perl modules matching a regular expression)

It seems like starting a package with a number ([0-9]) is a syntax error. You might want a check of the 1st character of the name.

See also:

Replies are listed 'Best First'.
Re^2: Testing for valid package names
by boftx (Deacon) on Nov 25, 2013 at 21:20 UTC

    Thanks!

    I thought about numbers as the first char, but that is legal for filenames so far as I know. I am still mulling that over.

    I wasn't aware of that Perl::Critic rule (not surprising) but the POD doesn't mention anything about the legal character set, only that a single-quote "'" should not be used even though it is a valid substitute for the double-colon '::' separator.

    It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
      IIRC, no (non-special) identifier is allowed to start with a number.

      Though I'm sure one can trick to enter them as key value pairs into the stash.

      Cheers Rolf

      ( addicted to the Perl Programming Language)

        You're right about numbers up front. I should have tried this to begin with:

        [jim@krakatoa perl]$ cat use23Skidoo.pl #!/usr/bin/perl -T use 5.008_008; use strict; use warnings FATAL => 'all'; use 23Skidoo; exit; __END__ [jim@krakatoa perl]$ ./use23Skidoo.pl syntax error at ./use23Skidoo.pl line 8, near "use 23" Execution of ./use23Skidoo.pl aborted due to compilation errors. [jim@krakatoa perl]$
        It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.