Subject: | M::P requires files that are excluded via only/except |
Hi simon,
take a look at the below script + terminal output. You'll see that only
one of the 2 files created should be loaded. The _dist_types method
returns the right one, BUT both are being require'd.
That's because the require code is part of this call:
my @plugins = $self->search_directories(@SEARCHDIR);
high up in M::P::Object->plugins. The exception are only applied AFTER
this call, which means it's too late to exclude them from being required.
This bug is causing some annoying warnings in bleadperl and is standing
in the way of a nice 5.10.1 release. If you could address this, that'd
be much appreciated.
Cheers,
P.S the CORE warning comes from:
eval "CORE::require $pack";
which should probably be written as:
eval "CORE::require( $pack )";
================================
package Foo;
use strict;
use Data::Dumper;
require Module::Pluggable;
my $only_re = __PACKAGE__ . '::\w+$';
Module::Pluggable->import(
sub_name => '_dist_types',
search_path => __PACKAGE__,
only => qr/$only_re/,
require => 1,
);
warn Dumper __PACKAGE__->_dist_types;
__END__
[kane@myriad-wifi ~...perl/module-pluggable-require-bug]$ bbedit x.pl
[kane@myriad-wifi ~...perl/module-pluggable-require-bug]$ mkdir Foo
[kane@myriad-wifi ~...perl/module-pluggable-require-bug]$ touch Foo/Bar.pm
[kane@myriad-wifi ~...perl/module-pluggable-require-bug]$ touch Foo/.Zot.pm
[kane@myriad-wifi ~...perl/module-pluggable-require-bug]$ perlc x.pl
Warning: Use of "CORE" without parentheses is ambiguous at (eval 13) line 1.
Couldn't require Foo::.Zot : Bareword "Zot" not allowed while "strict
subs" in use at (eval 13) line 1.
at /opt/lib/perl5/site_perl/5.8.8/Module/Pluggable.pm line 28
Couldn't require Foo::Bar : Foo/Bar.pm did not return a true value at
(eval 14) line 3.
at /opt/lib/perl5/site_perl/5.8.8/Module/Pluggable.pm line 28
$VAR1 = 'Foo::Bar';
[kane@myriad-wifi ~...perl/module-pluggable-require-bug]$ perlc
-le'print 1 if "." =~ /\w/'
[kane@myriad-wifi ~...perl/module-pluggable-require-bug]$