FireAndGlass
Programmer
I'm trying to retrieve the full path of the current executing script or module. I am aware that $FindBin::Bin will return the path of the toplevel executing module, but that is different. getcwd() will get the current working directory, but again, that can be different.
The situation I'm using it in is this. I have a perl script that is loading a module in another directory. The Module then needs to load another module, but it has to dynamically load a certain module from different paths based on certain conditions.
so basically i have this:
[tt]~/foo/MyScript.pl
~/bar/MyModule.pm
~/bar/a/MyOtherModule.pm
~/bar/b/MyOtherModule.pm[/tt]
in MyScript.pl:
[tt]use lib "~/bar";
use MyModule;[/tt]
in MyModule it will determine if directory a or b is the correct path, then add that to the libs path:
[tt]use $scriptingLib; // "a" or "b"
use MyOtherModule;[/tt]
However it is unable to find it. Upon failing to load, it says @INC will have "{ a /usr/nathan/bar . }"
I've been told that if one path is relative to another in @INC, upon a use call that it will search that relative path too. This can't be the case, otherwise it would find MyModule in /usr/nathan/bar/a.
I've scoured search engines and forums looking for an answer and can't seem to find one, yet this seems like a basic piece of information needed. Suggestions anyone? If it matters, I'm using ActivePerl 5.8g in a Cywin Bash shell.
The situation I'm using it in is this. I have a perl script that is loading a module in another directory. The Module then needs to load another module, but it has to dynamically load a certain module from different paths based on certain conditions.
so basically i have this:
[tt]~/foo/MyScript.pl
~/bar/MyModule.pm
~/bar/a/MyOtherModule.pm
~/bar/b/MyOtherModule.pm[/tt]
in MyScript.pl:
[tt]use lib "~/bar";
use MyModule;[/tt]
in MyModule it will determine if directory a or b is the correct path, then add that to the libs path:
[tt]use $scriptingLib; // "a" or "b"
use MyOtherModule;[/tt]
However it is unable to find it. Upon failing to load, it says @INC will have "{ a /usr/nathan/bar . }"
I've been told that if one path is relative to another in @INC, upon a use call that it will search that relative path too. This can't be the case, otherwise it would find MyModule in /usr/nathan/bar/a.
I've scoured search engines and forums looking for an answer and can't seem to find one, yet this seems like a basic piece of information needed. Suggestions anyone? If it matters, I'm using ActivePerl 5.8g in a Cywin Bash shell.