package Foo::Bar; use vars qw( $VERSION ); sub method { my $self = shift; my $ego = __PACKAGE__.'::_implement::helper'; print "Foo::Bar::method: method = ", $ego->($self),"\n" } package Foo::Bar::_implement; use Alter qw(ego); sub helper { ego( shift)->{'method'}; } sub Foo::Bar::objectPackage { "Foo::Bar::Object"; } sub Foo::Bar::new { my $class = shift; warn "Foo::Bar::new(@_), class = $class\n"; my $thingy = bless \ my $ref, $class; ego ($thingy,{@_}); print "new thingy = $thingy\n"; $thingy; } sub Foo::Bar::Object::method { my $self = shift; print "Foo::Bar::Object::method: \$self = $self\n"; my $corona = ego( $self); print "Foo::Bar::Object::method: method = ",$corona->{'method'},"\n"; print "helper returns ",helper($self),"\n"; } 1; #### #!/usr/bin/perl my $foo = Foo::Bar->new(method => 'helper'); print "foo isa $foo\n"; $foo->method; my $meth = $foo->objectPackage.'::method'; $foo->$meth; __END__ Foo::Bar::new(method helper), class = Foo::Bar new thingy = Foo::Bar=SCALAR(0x8205ba4) foo isa Foo::Bar=SCALAR(0x8205ba4) Foo::Bar::method: method = helper Foo::Bar::Object::method: $self = Foo::Bar=SCALAR(0x8205ba4) Foo::Bar::Object::method: method = helper helper returns helper #### package Foo::Bar::_implement; sub Foo::Bar::new { my $class = shift; my $thingy = bless \ my $ref, $class; package Foo::Bar; ego ($thingy,{@_}); package Foo::Bar::_implement; $thingy; }