Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Relative Module Path

by tadamec (Beadle)
on Aug 01, 2004 at 08:32 UTC ( [id://379032]=note: print w/replies, xml ) Need Help??


in reply to Relative Module Path

Why not combine P and M into a single unit? That way you're sure they won't be separated by a too-specific copy command.

Using your example, ~/P would become:

#!/usr/bin/perl -w use strict; use M; my $m = M->new; # # End of main program # package M; sub new{1}; 1;

Replies are listed 'Best First'.
Re^2: Relative Module Path
by pbeckingham (Parson) on Aug 01, 2004 at 15:01 UTC

    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.

      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'"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://379032]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-16 17:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found