freshfish has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone,
I have a simple script that I am trying to run that requires Net:POP3

use Net::POP3;

and I get the following error in SSH

Can't locate Net/POP3.pm in @INC...

However, I know that I have it because it was downloaded with one of my other scripts...and when I do a whereis net:pop3 it responds with net:pop3 leading me to believe that it is being found.

Do I change the line in the script with an absolute path to the Net:POP3 module that was uploaded to my server?

And, what exactly is the @INC??

Thank you!!

update (broquaint): title change (was 500 Script error (net:pop3))

Replies are listed 'Best First'.
Re: Existing module not found in path
by pzbagel (Chaplain) on May 26, 2003 at 05:51 UTC

    @INC is an array that contains the paths that Perl searches when it attempts to find the modules you have specified in use directives. The default is set at the compile-time of the Perl executable so if you want to use modules from other paths you have to either recompile Perl or change @INC when your script first starts up. If you've installed Net::POP3 in a local subdirectory you need to add that path to the @INC array before you load the module. The way to do this is in a BEGIN block in your script. The reason you must do this in the BEGIN block is because the use directive is a compile-time directive for perl and changing the @INC variable in the main part of your script (at run-time) would have no effect on it. The BEGIN block, however, is executed at compile time and the change to @INC would take effect before perl handled the use. Anyway, here's a simple code snippet:

    sub BEGIN { unshift @INC, "<path where Net::POP3 is installed>"; } use Net::POP3; # script continues

    HTH

      WOW! Thanks guys...that was a great help and real quick. Thank you :))
Re: Existing module not found in path
by Tanalis (Curate) on May 26, 2003 at 07:33 UTC
    Alternatively, as all you're doing is adding a non-existant path to the include list, you can simply
    use lib '/path/to/the/module'; use Net::POP3;
    That will have Perl look in the lib path you specify, as well as in @INC, for the Net::POP3 (and all subsequent) modules.

    Hope that helps.

    -- Foxcub
    #include www.liquidfusion.org.uk