FindBin question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I've a program, which uses FindBin to locate other
modules, in the following way:

# This is file !
use warnings;
use strict;
use FindBin;
use lib "$FindBin::Bin";
# is in the same directory as
use Support; # <---- found via FindBin magic

This worked fine and I was very happy with this. Now I have a different
program,, in a different directory, which is supposed to use above
under the following assumptions:
- should be called via a call to system("...")
- It is known that happens to be in a directory which is not
$ENV, but in'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 which invokes

# This is file !
use lib "....";
# Temporarily append @INC to PATH when calling

Indeed, gets invoked, as expected, but then, claims
it is unable to find the module . A look at @INC reveals
the directory of is incorporated in the @INC path, but not

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


with the following conditions:

- calls via system().
- uses
- The use statement in should not mention the path $HOME/foo,
so that
I can easily move the files around to different locations.
- The use statement in *does* mention the path $HOME/foo (no
need to be flexible here)
- $HOME/bar/ and $HOME/foo/ should both be callable
from the command line

Any ideas how to do this?


Re: FindBin question

On 12/13/2006 06:56 AM, Ronny wrote:
Quoted text here. Click to load it

Perhaps try this in

$ENV =~ s;
$ENV =~ s;
system '';

Quoted text here. Click to load it

In addition to the above I wrote, you could also create a shell script
that sets PATH and PERL5INC before invoking

Re: FindBin question

Quoted text here. Click to load it

Actually, if you look at my posting, you see that PATH *is* set so that
points to the myutil directory. Strangely this is not sufficient to
FindBin the module in this particular case.

Extending PERL5LIB would indeed solve the problem, but it would not
explain why FindBin fails to do its job in my example.


Site Timeline