Tobias Eichner <[EMAIL PROTECTED]> wrote:
> I have created a Perl library that I want to use with my
> programs (via require). However the Perl library should be
> placed at a sub-folder of the working directory (the place
> where the program runs).
>
> For example:
>
> /my/custom/path/ is the location of the program.
> /my/custom/path/libraries/ is the location where I want to
> place my Perl libraries in.
>
> How can I implement this considering that my Perl program
> will run on different platforms with different ways of writing paths ?
>
> Would it work to use require "./libraries/mylib.pl" on all
> platforms (*nix, Windows, Mac, something else) ? I don't
> think so. Not sure if paths can be used overall with require
> (not tried it yet).
>
> My idea would be to use the standard module File::Spec to add
> the path to my libraries to @INC. For example:
>
> my $mylibpath = File::Spec->rel2abs("libraries/");
> unshift(@INC,$mylibpath);
I'd use
use FindBin;
use File::Spec;
use lib File::Spec->catdir( $FindBin::Bin, 'lib' );
HTH,
Thomas
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/