Re: help with versioning modulesby afoken (Canon)
|on Nov 20, 2020 at 18:59 UTC||Need Help??|
Filename and package name do not match.
If the file name (relative to the include path) is My::Foo, and you load the module in foo_version_test.pl by use My::Foo, then the package name should be My::Foo, not Foo. Loading the module creates a global variable named $Foo::VERSION, but use My::Foo 1.0 tests for a variable named $My::Foo::VERSION.
It is perfectly legal to have package names in a module that to not match the file name, so perl does not warn. But it causes a lot of trouble (see Breaking Tie::Hash into three modules for an example). As a rule of thumb, make sure that package names and file names match.
Update: Modern versions of perl also allow package My::Foo 1.0;, implicitly setting $My::Foo::VERSION and matching use My::Foo 1.0. See also package.
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)