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. #- 1st Method -----# use lib qw(/usr/www/htdocs/domain-name/cgi-bin/lib); use DGStanLib; #- 2d Method -----# use File::Find; my $index = index($ENV{SCRIPT_FILENAME},'cgi-bin/'); my $cgi_path = substr($ENV{SCRIPT_FILENAME},0,$index+8); my $mod_path; find (\&wanted, $cgi_path); sub wanted { if (!-d && $File::Find::name =~ m/DGStanLib\.pm/) {$mod_path = $File::Find::dir;} } use lib $mod_path; use DGStanLib; #- 3d Method -----# use File::Find; my $index = index($ENV{SCRIPT_FILENAME},'cgi-bin/'); my $cgi_path = substr($ENV{SCRIPT_FILENAME},0,$index+8); my $mod_path; find (\&wanted, $cgi_path); sub wanted { if (!-d && $File::Find::name =~ m/DGStanLib\.pm/) {$mod_path = $File::Find::dir;} } use FindBin qw($Bin); $Bin .= $mod_path; use lib "$Bin"; use DGStanLib; Ron Goral -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>