FindBin question
- From: "Ronny" <ro.naldfi.scher@xxxxxxxxx>
- Date: 13 Dec 2006 04:56:12 -0800
I've a program myutil.pl, which uses FindBin to locate other
modules, in the following way:
#!/usr/local/bin/perl
# This is file myutil.pl !
use warnings;
use strict;
use FindBin;
use lib "$FindBin::Bin";
# Support.pm is in the same directory as myutil.pl
use Support; # <---- found via FindBin magic
This worked fine and I was very happy with this. Now I have a different
program,
newprog.pl, in a different directory, which is supposed to use
myutil.pl above
under the following assumptions:
- myutil.pl should be called via a call to system("...")
- It is known that myutil.pl happens to be in a directory which is not
in
$ENV{PATH}, but in newprog.pl's @INC
(I know that the second assumption is a bit esoteric, but in this
particular case
this is how it is).
Here is the excerpt from newprog.pl which invokes myutil.pl:
#!/usr/local/bin/perl
# This is file newprog.pl !
use lib "....";
......
# Temporarily append @INC to PATH when calling myutil.pl
system('PATH=$PATH:'.join(':',@INC)." myutil.pl");
Indeed, myutil.pl gets invoked, as expected, but then, myutil.pl claims
that
it is unable to find the module Support.pm . A look at @INC reveals
that
the directory of newprog.pl is incorporated in the @INC path, but not
that
of myutil.pl.
Maybe I misunderstood something in the way FindBin works. How do
I deal with this situation? In a short way, the files are located like
this:
$HOME/foo/myutil.pl
$HOME/foo/Support.pm
$HOME/bar/newprog.pl
with the following conditions:
- newprog.pl calls myutil.pl via system().
- myutil.pl uses Support.pm.
- The use statement in myutil.pl should not mention the path $HOME/foo,
so that
I can easily move the files around to different locations.
- The use statement in newprog.pl *does* mention the path $HOME/foo (no
need to be flexible here)
- $HOME/bar/newprog.pl and $HOME/foo/myutil.pl should both be callable
from the command line
Any ideas how to do this?
Ronald
.
- Follow-Ups:
- Re: FindBin question
- From: Mumia W.o
- Re: FindBin question
- Prev by Date: Re: Passing username and password using LWP::UserAgent
- Next by Date: Re: FindBin question
- Previous by thread: PerlMagick - Annotate - no fonts
- Next by thread: Re: FindBin question
- Index(es):
Relevant Pages
|
|