> Greetings -
> 
> I am having trouble locating and using modules that are not in the current
> directory of a cgi script.  For this test, I know the directory structure
> looks like this:
> 
> cgi-bin/test/test.cgi
> cgi-bin/lib/DGStanLib.pm
> 
> However, this script and the required modules may be used by others and I
> cannot guarantee its location. As such, I want to locate a module
located in
> cgi-bin/lib to be "use"d by a cgi script in cgi-bin/test.  Below are three
> methods I've tried for doing this.  The first, of course, explicitly names
> the path to the module. This will not be possible to do. Mainly because I
> cannot be sure of the path. In the second, I am trying to locate the
cgi-bin
> directory and build the path from there.  "use lib", however, does not
> expand variables, so the value of $mod_path is not being added to @INC. In
> the third method, I've added FindBin.  However, it is only going to locate
> directories in cgi-bin/test. Again, though, even $Bin is not added to
@INC.
> Please help.  This is very frustrating.
> 

I am assuming from your description that the path to 'lib' is always
relative to the script location?? How about,

use FindBin qw($Bin);
use lib "$Bin/../lib";

This works for me, again, assuming 'lib' is always relative to 'test'. 
I take this one step further and place a 'lib' at the top level of the
'httpd' directory so that it may be used across multiple vhosts, then
include a 'lib' just outside of the 'cgi-bin' as well so that it is not
in a script aliased directory but can seem more vhost dependent. 
Tweaking the above to fit my format I use,

use FindBin;
use lib "$FindBin::Bin/../../lib";
use lib "$FindBin::Bin/../lib";

This also allows me to override any base module at a vhost specific level.

Does this help?

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to