Ron Goral wrote:
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.
For a script I'm distributing, I have:
use lib 'lib';
and I tell the users to either put the modules in a subdirectory 'lib'
to the directory where the script is located, or change the "use lib"
statement to include the full path.
But the solution with FindBin, posted by Wiggings and Bob, is better.
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.
Yes it does. One problem is that "use" statements are executed at
compile time, while you set the variable at run time. You can put the
code within a BEGIN block to fix that. Another problem seems to be
that you have File::Find look for the module in the cgi-bin directory,
while the module is located elsewhere.
But don't you overdo it by using File::Find to look up the path to a
module?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>