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

Austin Schutz tex at off.org
Sun Jun 18 20:48:43 PDT 2006

On Sun, Jun 18, 2006 at 02:31:15AM -0700, Eric Wilhelm wrote:
> # from Austin Schutz
> # on Friday 16 June 2006 01:02 pm:
> >use lib '/usr/local/apache/cgi-bin/my';
> fair enough
> >and
> >
> >require 'my_lib.pl';
> no.  use my_lib;
>   strace -o /tmp/stracefile perl -e "require './my_lib.pl'"
>   grep my_lib.pl /tmp/stracefile | grep '^open' | sed 's/ .*//'
>   strace -o /tmp/stracefile perl -e "require 'my_lib.pl'"
>   grep my_lib.pl /tmp/stracefile | grep '^open' | sed 's/ .*//'
> On my box, the output shows searches through hither and yon in the 
> second case.

	Which it should - it should look through your INC path and all
associated goodies like auto/ for the file. Doing the use lib should have it
early in the path so it doesn't have to look very far though.
	But anyway, I've verified beyond any doubt they are still the same
file. For some sets of parameters of the program it helps to have the require
at the top of the list of required items. Other times it doesn't help.
	Also I haven't changed to 'use' because the original code didn't use
use.  I guess my feeling is that if I can't even get it to work without the
symlinks changing the syntax is going to get me in even deeper water. But who
knows - worth a try.


More information about the Pdx-pm-list mailing list