PAR and Module::Pluggable

LTjake on 2004-08-26T11:58:15

Unfortunately, I had to submit a bug report yesterday. PAR and Module::Pluggable do not play well together. In theory this test should pass:

package MyApp;

use PAR qw( plugins/*.plugin );
use Module::Pluggable;

sub new {
	my $class = shift;
	return bless { }, $class;
}

package main;

use Test::More tests => 1;

my $app = MyApp->new;

is( ( $app->plugins() )[ 0 ], 'MyApp::Plugin::Test' );

Note: there should be a plugins/test.plugin file which is really just a PAR file (which is really just a zip file). It should house the MyApp::Plugin::Test module.

This doesn't work because PAR does some lazy loading and when Module::Pluggable checks @INC, nothing is there. You can work around this by adding a require MyApp::Plugin::Test; just about anywhere -- but that sort of defeats the purpose.