in reply to Re: Howto set path for local package in a Perl code
in thread Howto set path for local package in a Perl code

Dear holli,

Thanks so much for the reply, however after following your suggestion with this header in mycode.pl
use strict; use warnings; use lib "/home/neversaint/MyPerl/src"; use MYPACKAGE;
what I get is this...
~/MyPerl/src $ perl -c src/mycode.pl # gives Can't locate MYPACKAGE.pm in @INC (@INC contains: home/neversaint/MyPe +rl/src /home/neversaint/lib/perl5/site_perl/5.8.5/i386-linux-thread-m +ulti/5.8.5/i386-linux-thread-multi
In MYPACKAGE.pm what I have is this:
# plain header nothing here... # straight go to the functions.... sub some_func { # do sth; return $soth } 1;
Although I have no problem at all running mycode.pl in src/ directory : ~/MyPerl $ perl mycode.pl someparam

Did I still miss anything?

---
neversaint and everlastingly indebted.......

Replies are listed 'Best First'.
Re^3: Howto set path for local package in a Perl code
by davorg (Chancellor) on Jun 01, 2006 at 10:39 UTC
    Can't locate MYPACKAGE.pm in @INC (@INC contains: home/neversaint/MyPerl/src /home/neversaint/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/5.8.5/i386-linux-thread-multi

    That error message still gives the path without the leading slash. Which makes me think that perhaps you haven't edited the file successfully to correct that.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re^3: Howto set path for local package in a Perl code
by krisahoch (Deacon) on Jun 01, 2006 at 17:56 UTC
    neversaint, try this code.
    This is for you script file 'mycode.plx'
    # In script file named: mycode.plx use strict; use warnings; use diagnostics; # This just gives you more info. use lib '/home/neversaint/MyPerl/src'; use MyPackage; # Now the rest of your code.
    This is for your package file 'MyPackage.pm'
    # In MyPackage.pm package MyPackage; use strict; use warnings; use diagnostics; sub some_function { print("My some function"); }
    Now here is the important part. The use statement, the file name, and the package declaration MUST all be in the same case.
    • Use statement: use MyPackage;
    • File Name: MyPackage.pm
    • Package statement: package MyPackage;
    Kristofer Hoch