Thanks for the additional information, this is starting to make more sense now. Is it correct that in the context of a "use" statement (example: use My::Foo), the :: effectively represent a filesystem directory separator character (e.g. '/' in Linux), the last word with a ".pm" appended to it represents the module's filename, and this path (My::Foo, e.g. /My/Foo.pm) is then appended to each base path in @INC to determine where Perl will search for the listed module?
If I'm understanding everything correctly, my original example is failing because the use My::Foo 1.0 statement is using My::Foo as a search path to find My/Foo.pm (relative to /home/user/perl_modules/lib/perl5) but it is also treating My::Foo as a package name to look for a version variable My::Foo::$VERSION. The only way both of these can be correct is if the package name matches the exact name specified to use the module. I was able to fix everything by either doing this:
use lib '/home/user/perl_modules/lib/perl5/My'; use Foo 1.0;
Or by renaming the package to My::Foo and then updating the code references accordingly.
Also after I created the My/Bar.pm file as written in your post and then another file to "use My::Bar" and then call the Xyzzy->say_it function, I received the following error:
My/Bar.pm did not return a true value at ./bar_test.pl line 4. BEGIN failed--compilation aborted at ./bar_test.pl line 4.
I was able to fix this by adding a "1;" to the end of Bar.pm. Do all packages need to end with "1;"?
> The package is named Xyzzy, so you must call the sub with Xyzzy::say_it (or Xyzzy->say_it if you prefer, since it will just ignore all parameters passed anyhow).
Can you elaborate on this a little bit? What exactly is the difference between calling say_it with :: vs ->?
In reply to Re^4: help with versioning modules
by Special_K
in thread help with versioning modules
by Special_K
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |