This is how modules work:
Our guinea pig will be LWP::UserAgent. You have the line "use LWP::UserAgent" in your code. Perl converts the module name into something that loosk like a file path (the :: becomes a / and a .pm is tacked onto the end, so LWP::UserAgent becomes "LWP/UserAgent.pm").
It then loops through the directories in @INC and, for each directory, it takes on LWP/UserAgent.pm to the end. As soon as it finds that such a file exists, it stops searching and includes that module.
So if @INC contains this:
Code:
@INC = (
'C:/Perl/lib',
'C:/Perl/site/lib',
'.',
);
then Perl will search for these files:
Code:
C:/Perl/lib/LWP/UserAgent.pm
C:/Perl/site/lib/LWP/UserAgent.pm
./LWP/UserAgent.pm
If it doesn't find one, it will say "Can't locate LWP/UserAgent.pm in @INC (@INC contains: C:/Perl/lib; C:/Perl/site/lib; .)"
Having said that, just put your module in a place where Perl will find it giving it a file name and path that matches the module's name. As a tip: you don't have to put it in the main Perl module paths, you can place it in a folder that's next to your Perl script. So if you have a folder named "mymodules" in the same place as your Perl script, you do...
Code:
use lib "./mymodules";
use My::Custom::Module;
And that'll try to load "./mymodules/My/Custom/Module.pm" before searching the rest of @INC (the "use lib" module essentially puts your own custom search paths onto the front of the @INC array; you can override installed modules with custom versions this way).
-------------
Cuvou.com | My personal homepage
Project Fearless | My web blog