develooper Front page | perl.perl5.porters | Postings from June 2012

require's error message for "absolute" paths (was Re: almostunreachable code in pp_require)

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
June 28, 2012 07:44
Subject:
require's error message for "absolute" paths (was Re: almostunreachable code in pp_require)
Message ID:
20120628144401.GA8902@plum.flirble.org
On Wed, Jun 27, 2012 at 04:35:00PM -0000, Father Chrysostomos wrote:
> Nicholas Clark asked:
> > Is there a way?
> 
> As of, um, c9d5e35e, that appears to be the only way.

Hmm. Perhaps it *should* be more reachable. Currently, if one does this:

$ ./perl -Ilib -e 'require "less.pm"; warn $INC{"less.pm"}'
lib/less.pm at -e line 1.

whereas this fails with this message:

$ ./perl -Ilib -e 'require "./less.pm"; warn $INC{"less.pm"}'
Can't locate ./less.pm in @INC (@INC contains: lib /usr/local/blead/lib/perl5/site_perl/5.17.2/darwin-2level /usr/local/blead/lib/perl5/site_perl/5.17.2 /usr/local/blead/vendor/lib/perl5/vendor_perl/5.17.2/darwin-2level /usr/local/blead/vendor/lib/perl5/vendor_perl/5.17.2 /usr/local/blead/lib/perl5/5.17.2/darwin-2level /usr/local/blead/lib/perl5/5.17.2 .) at -e line 1.

but that's not totally true, as the @INC search wasn't attempted (at least,
not for directories. coderefs are checked)


The message changed in commit cf42f822f042b255 (in Jan 2002). It also gives:

$ ./perl -Ilib -e 'require "less.pm"; warn $INC{"less.pm"}'
lib/less.pm at -e line 1.
$ ./perl -Ilib -e 'require "./less.pm"; warn $INC{"less.pm"}'
Can't locate ./less.pm in @INC (@INC contains: lib /usr/local/lib/perl5/5.7.2/x86_64-linux /usr/local/lib/perl5/5.7.2 /usr/local/lib/perl5/site_perl/5.7.2/x86_64-linux /usr/local/lib/perl5/site_perl/5.7.2 /usr/local/lib/perl5/site_perl .) at -e line 1.

whereas at commit 3d1a39c8be0d615d, 2 earlier it was this:

$ ./perl -Ilib -e 'require "less.pm"; warn $INC{"less.pm"}'
lib/less.pm at -e line 1.
$ ./perl -Ilib -e 'require "./less.pm"; warn $INC{"less.pm"}'
Can't locate ./less.pm at -e line 1.

It's a side effect of an intended behaviour change - that coderefs in @INC
should be tried for all pathnames. Thread starts here:

http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-01/msg00875.html


But I'm not exactly sure. If there are no coderefs in @INC, it seems obvious
that the message should be the old one, not mentioning @INC. But if there
are coderefs in @INC, what should be displayed in the message? All of @INC?
Or just the bits that were tested?

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About