3分間クッキング

かぜぶろさんのご意見頂戴!!
即興修正。
とりあえず動いた。


package CGI::Application::Pluggable;
use strict;
use warnings;
use base 'CGI::Application';
use UNIVERSAL::require '0.10';
our $VERSION = '0.03';
sub import {
my ( $self, @options ) = @_;
my $caller = caller(0);
{
no strict 'refs';
push @{"$caller\::ISA"}, $self;
}
for my $option ( @options ) {
if ( ref $option eq 'HASH') {
my ($plugin,$imports) = each(%{$option});
my $plaggable = $self->_mk_plugin_name($plugin);
$plaggable->use( @{$imports} ) or die $@;
}
else {
my $plaggable = $self->_mk_plugin_name($option);
$plaggable->use or die $@;
}
}
}
sub _mk_plugin_name {
my $self = shift;
my $name = shift;
return "CGI::Application::Plugin::$name";
}
1;