package My::Parent;
use warnings;
use strict;
sub import {
my $name = { short => 'frob',
long => 'frobnicate'
}->{ $_[1] };
no strict 'refs';
*{$name} = *_frobnicate;
}
sub new { bless $_[1], $_[0] }
sub _frobnicate { $_[0]{a} + $_[0]{b} }
__PACKAGE__
####
#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 1;
use My::Parent 'long';
my $p = 'My::Parent'->new( { a => 2, b => 3 } );
is $p->frobnicate, 5, 'frobnicates';
####
package My::SimpleChild;
use warnings;
use strict;
use parent 'My::Parent';
sub import {
shift->SUPER::import('short');
}
__PACKAGE__
####
#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 1;
use My::SimpleChild;
my $s = 'My::SimpleChild'->new({ a => 2, b => 3 });
is $s->frob, 5, 'frobs';
####
package My::MooseChild;
use Moose;
use MooseX::NonMoose;
extends 'My::Parent';
has a => (is => 'ro');
has b => (is => 'ro');
sub import { shift->SUPER::import('short') }
sub FOREIGNBUILDARGS {
my ($class, %args) = @_; \%args
}
no Moose;
__PACKAGE__->meta->make_immutable
####
#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 1;
use My::MooseChild;
my $m = 'My::MooseChild'->new(a => 2, b => 3);
is $m->frob, 5, 'frobs';
####
package My::DelegChild;
use Moose;
use My::Parent 'short';
has a => (is => 'ro');
has b => (is => 'ro');
has _parent => (is => 'ro',
lazy => 1,
default => sub { my ($self) = @_;
'My::Parent'->new({ a => $self->a,
b => $self->b });
},
handles => ['frob']);
no Moose;
__PACKAGE__->meta->make_immutable
####
#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 1;
use My::DelegChild;
my $ch = 'My::DelegChild'->new(a => 2, b => 3);
is $ch->frob, 5, 'frobs';
####
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,