in reply to Re: Relative Module Path
in thread Relative Module Path

Why not combine them? Because there are many modules, and many more programs that use them. The example shown was just that - an example. The real code is somewhat more complex.

Replies are listed 'Best First'.
Re^3: Relative Module Path
by tadamec (Beadle) on Aug 02, 2004 at 00:59 UTC

    Ah, gotcha.

    I use something like this for situations where I have a local "lib" directory. You could probably modify it somewhat:

    #!/usr/bin/perl use strict; # Always use strict. my $BASEPATH; # # Include path magic. # BEGIN { use File::Basename; use File::Spec; my $PROGRAM = File::Spec->rel2abs( $0 ); ( undef, $BASEPATH, undef ) = fileparse( $PROGRAM ); $BASEPATH = File::Spec->catdir( $BASEPATH, "../" ); my $LIBPATH = File::Spec->catdir( $BASEPATH, "lib" ); eval " use lib '$LIBPATH'"; }

    If you want to keep the module files in the same directory this BEGIN block should work (I haven't tested it):

    BEGIN { use File::Basename; use File::Spec; my $PROGRAM = File::Spec->rel2abs( $0 ); ( undef, $BASEPATH, undef ) = fileparse( $PROGRAM ); eval " use lib '$BASEPATH'"; }