Rob Hanson sent this to me the other day when I asked a similar question.  I
had been using "-I C:/Path/Of/Library/" (I was later informed that this was
more for use when using in-house modules) in the first line of my scripts,
but he listed some alternatives that maybe more appropriate - see below:


Actually there are three (maybe 4) ways...

use lib '/path/to/your/library/';

...or..

BEGIN {
        @INC = ('/path/to/lib', '/path/to/sitelib/');
        # ...or usr push or unshift to 
        # add to the current @INC
}

....or...

Add the path in your environment vars...

PERL5LIB='/path/to/lib'

Where you set the environment path depends on your system.  In NT modify the
vars in the Control Panel/System, in Apache in the config, in DOS in
autoexec.bat, in Unix/Bash the .bash_profile, etc.

See "perldoc -q lib" (which is from Perl FAQ #8)

Rob



-----Original Message-----
From: David Kirol [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 28, 2001 7:58 PM
To: [EMAIL PROTECTED]
Subject: @INC


Hi All,
        This is one of those posts: 'How would I do this if I were a real
perl
programmer...'
First, the problem. Windoz NT with  Apache server (windoze version) and
cygwin with perl 5.6.1 (NOT activestate).
Apache is configured for CGI and perl can find CGI.pm in cygwin and windoz
shell but not when executed as

use CGI;

in a perl script (residing in cgi-bin directory) Error log shows 'cant find
CGI.pm in @INC'
So I employed a begin block:
BEGIN {
        my $addinc;
        foreach (@INC) {
                if (m|^/usr(/.+)|) {
                        $addinc = "/cygdrive/d/cygwin".$1;
                        push @INC, $addinc;
                }
        }
}
which, in effect takes a path like /usr/local/lib/perl5
and changes it to /cygdrive/d/cygwin/local/lib/perl5
then adds the 'new' path to the end of the @INC array. This allows me to
'use CGI' from Apache
but there must be a better way! (I like ActiveState but this must be cygwin
perl, I like Linux
but this has to be WinNT) Any suggestions?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to