On 2/5/07, Robert Hicks <[EMAIL PROTECTED]> wrote:

If I have a CGI script and I have my modules in a local directory
("lib") would the directory structure be like this:

Trakker.pm
Trakker::Dispatch.pm
Takker::SQL.pm
Trakker::Conf.pm

/lib/Trakker.pm
/lib/Trakker/Dispatch.pm
/lib/Trakker/SQL.pm
/lib/Trakker/Conf.pm

Could be, although the system /lib directory isn't usually my choice.
But are you *manually* installing those module files by copying them
into place? You're working too hard. If you build and install modules
in the usual way -- starting with the Makefile.PL -- you get to be
done with it once you choose the prefix.

Another advantage: You could run your tests on the installed modules,
so you'd know they're properly installed.

I have added "lib" to my @INC:

use lib qw( lib/ );

Wait, what? That can't be right. That is a relative path, and the CGI
specification doesn't tell you which directory you're starting in. It
might be the directory that contains your script, but it might be
anything else. CGI programs should use only absolute path names, at
least until they've successfully changed into a known directory. (And
since modules (and pragmas like lib) load at compile time, you would
have to chdir before you load the modules. Better just to give lib an
absolute path name, which is one that starts with a slash. Or more
than one path name, if there's more than one place modules might be
found.)

   use lib '/lib';
   use lib '/home/sigzero/lib';

Sometimes, though, it's difficult to debug what's in your CGI
environment. That's what Inside is for:

   http://search.cpan.org/~phoenix/Inside-1.01/

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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


Reply via email to