[Pdx-pm] require './file' vs. require 'file'

Tom Phoenix rootbeer at redcat.com
Sat Jun 17 11:15:11 PDT 2006

On 6/16/06, Austin Schutz <tex at off.org> wrote:

>         In the code there is:
> require './my_lib.pl';
>         where ./my_lib.pl is a symlink to ../my/my_lib.pl.
>         The full path to the actual file is:
> /usr/local/apache/cgi-bin/my/my_lib.pl

This is a red flag: The CGI spec fails to specify the current working
directory used when a CGI program is invoked, alas. So I'm obliged to
say that these relative paths may not resolve in the obvious way.

>         So, because I think the symlink system is stinky I would like to
> do:
> use lib '/usr/local/apache/cgi-bin/my';
> and
> require 'my_lib.pl';
>         but that causes the code to fail without error.

Could it also, separately, be loading './my_lib.pl'? Normally, require
won't load the same library twice; but it can if the code asks for it
under different names. Check %INC at runtime to see what actually

Good luck with it!

--Tom Phoenix

More information about the Pdx-pm-list mailing list