- Let the first line in the .pm file be package Red::Green::Blue;.
- The .pm file should be named Blue.pm.
- The .pm file must be stored at dir/Red/Green/Blue.pm.
- In the perl program where you want to use this module, include use lib "dir";. This tells Perl to also look in dir when searching for modules. (this basically adds an entry to @INC).
- In the same program, after the previous line, include use Red::Green::Blue;. This tells Perl to find path/Red/Green/Blue.pm for all paths in @INC, including dir.
When this will not work -
- If you get the error Can't locate loadable object for module qwe, then the module is a non-pure Perl module and uses external code (e.g. C code), which should come in a .so file.
- The easy way is to do sudo cpan Red::Green::Blue and install the module.
- If you do this, sure to remove the file dir/Red/Green/Blue.pm so that Perl does not use it instead of the installed module.
No comments:
Post a Comment