in reply to Calling an intermediate method

The approaches of tobyink and choroba sound like they are what you want (and they're certainly more sophisticated than my approach), but would the following be useful?

>perl -wMstrict -e "use 5.014; ;; package Foo { ;; sub new { bless [] }; ;; sub msg { my $self = shift; my ($destination) = @_; printf qq{On my way to '%s'. }, $destination; my $coderef = $self->can($destination); return print qq{Cannot get there. \n} unless $coderef; $self->$coderef($destination); } ;; sub Berlin { my $self = shift; print qq{I am in $_[0]! \n}; } ;; sub Paris { my $self = shift; print qq{Arrived in $_[0]! \n}; } ;; } ;; my $obj = Foo->new; $obj->msg('Berlin'); $obj->msg('Paris'); $obj->msg('London'); " On my way to 'Berlin'. I am in Berlin! On my way to 'Paris'. Arrived in Paris! On my way to 'London'. Cannot get there.

Update: See perlobj, perltoot, perltooc for info on can(). (Update: perltoot and perltooc exist for Perl 5.14, but have been superceded for 5.18. So you're on your own...)