Not quite sure what you mean. Maybe like this?
package Foo { sub new { bless [] }; sub msg { my $self = shift; printf "On my way to '%s'\n", @_; } sub Berlin { my $self = shift; $self->msg('Berlin'); print "I'm in Berlin!\n"; } sub Paris { my $self = shift; $self->msg('Paris'); print "I'm in Paris!\n"; } }; my $obj = Foo->new; $obj->Berlin();
Or maybe you mean like this?
package Foo { sub new { bless [] }; sub msg { my $self = shift; printf "On my way to '%s'\n", @_; } sub Berlin { my $self = shift; print "I'm in Berlin!\n"; } sub Paris { my $self = shift; print "I'm in Paris!\n"; } }; use Class::Method::Modifiers qw( install_modifier ); for my $city (qw/ Paris Berlin /) { install_modifier "Foo", before => $city => sub { my $self = shift; $self->msg($city); }; } my $obj = Foo->new; $obj->Berlin();
In reply to Re: Calling an intermediate method
by tobyink
in thread Calling an intermediate method
by trizen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |