Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Can't locate ./cgi-bin/upload_lib.pl in @INC (@INC contains: /usr/lib/ +perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/per +l5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5 +.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-l +inux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/ven +dor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/ +5.8.0 .) at upload.cgi line 5.
My file requires upload_lib.pl which is in the CGI directory but it can't find it. The path to CGI is /var/www/cgi-bin and the path to the directory I am calling this from is /var/www/html.

What am I doing wrong with require ("./cgi-bin/upload_lib.pl");?

Replies are listed 'Best First'.
Re: Can't locate file
by maa (Pilgrim) on Nov 24, 2004 at 07:42 UTC

    If you're in /var/www/html and CGI is /var/www/cgi-bin then you need "../cgi-bin/upload_lib.pl" not "./cgi-bin/upload_lib.pl"... looks like a late-night typo to me :-)

    HTH - Mark

Re: Can't locate file
by strat (Canon) on Nov 24, 2004 at 07:42 UTC

    I guess the working directory is not the one you think it is...Either try to load upload_lib.pl with a full path, or load it with a relative path to the main program with FindBin, e.g. if your upload.cgi is also in cgi-bin

    use FindBin; require "$FindBin::Bin/upload_lib.pl";

    The variable $FindBin::Bin contains the path to the executed script, and under normal circumstances it works well. See also FindBin is broken (RE: How do I get the full path to the script executing?)

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"