Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Module::Runtime is probably what you want to use for this. Here are the relevant parts...
This is more restrictive than your current check - in particular it excludes all non-ASCII word characters. This is because Unicode file names are handled pretty inconsistently across different file systems and Perl versions. Note that this is really a module name check; not a package name check. Modules are files on the filesystem; packages are namespaces. Package names are a lot more relaxed than module names; for example, the space character can be used as a package name:
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
In reply to Re: Testing for valid package names
by tobyink
|
|