你已经看过了吗
Moose::Cookbook::Basics::DateTime_ExtendingNonMooseParent
和
MooseX::NonMoose
?
MooseX::Declare
和
MooseX::NonMoose
package My::App;
use Moose;
use MooseX::NonMoose;
extends 'CGI::Application';
sub setup {
my $self = shift;
$self->start_mode( 'main' );
$self->run_modes(
map { $_ = $_->name;
/^rm_ (?<rm>.+) $/x ? ( $+{rm} => $_ ) : ()
} $self->meta->get_all_methods
);
}
"My::App"
package My::Login;
use Moose;
extends 'My::App';
sub rm_main { 'it works!' }
"My::Login"
#!/usr/bin/perl
use strict;
use warnings;
# For testing on the command line
use FindBin qw( $Bin );
use lib $Bin;
use My::Login;
my $app = My::Login->new;
$app->run;
C:\Temp\f> t
Content-Type: text/html; charset=ISO-8859-1
it works!