Skip Menu |

This queue is for tickets about the Module-Locate CPAN distribution.

Report information
The Basics
Id: 30523
Status: resolved
Priority: 0/
Queue: Module-Locate

People
Owner: BROQ [...] cpan.org
Requestors: dagolden [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.7
Fixed in: 1.79



Subject: Two different problems with %INC on Unix and MSWin32
There are two subtle problems with how %INC is handled. First, by setting %INC for a module, a subsequent use or require will shortcut and not actually load the module. (See "perldoc -f require") In other words, this won't work: use Module::Locate qw/locate/; my $mod = "Text::Wrap"; eval "require $mod" if locate $mod; So defaulting to $Global=1 is bad -- if you want to maintain a cache, you should do so with a lexical hash within the Module::Locate package and leave %INC alone. There's another subtle bug on MSWin32 -- because you use File::Spec to assemble the path, you wind up with backslashes in %INC (e.g. "Text\Wrap.pm") -- which then doesn't show the require bug above, but isn't how %INC is organized and other things that check %INC fail. Of course, if you just leave %INC alone, this bug goes away. I'm attaching a test file that demonstrates the two bugs. David
Subject: module-locate-bug.pl
use strict; use warnings; use Test::More tests => 4; use Module::Locate qw/locate global 1/; ok( locate( "Text::Wrap" ), "found Text::Wrap" ); # fails on MSWin32 ok( exists $INC{"Text/Wrap.pm"}, "found Text/Wrap.pm in \%INC" ); use_ok( "Text::Wrap" ); eval { wrap( "ABC 123" ) }; is( $@, q{}, "No error calling wrap()" ); # fails on *nix
Fixed in 1.79 -- thanks.