in reply to Problem with use lib?

The current directory is, by default, the last item in the @INC array. The only difference that your use lib statement makes is to make it also the first item in @INC.

It's already been suggested to you that the current directory might not be the one that contains the running script. To add the script's directory to @INC you should look at the FindBin module.

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

"Perl makes the fun jobs fun
and the boring jobs bearable" - me

Replies are listed 'Best First'.
(tye)Re: Problem with use lib?
by tye (Sage) on Dec 27, 2000 at 20:54 UTC

    See FindBin is broken (RE: How do I get the full path to the script executing?) for my thoughts on FindBin. It mostly works but it does so by spinning its wheels in the most perverse ways. The whole design is based around a false assumption. If you have Perl 5.6 or higher, I'd recommend the following:

    use File::Spec; use File::Basename qw(dirname); use lib dirname( File::Spec->rel2abs($0) );
    but that may be overkill since it can end up putting the full path to "." in the front of @INC, so you can probably get away nicely with:
    BEGIN { use File::Basename qw(dirname); use lib dirname( $0 ); }
    but be warned that doing a chdir() between this and a require could cause surprises.

            - tye (but my friends call me "Tye")