http://www.perlmonks.org?node_id=602338


in reply to on the fly methods

sub makeMethod { my $this = shift; $this->{_coderef} = eval $this->{_codestring} } sub callMethod { my $this = shift; $this->{_coderef}->(@_) }

If you want to do something like this:

$this->makeMethod( "somenewname", "some code" ); $this->somenewname();
then I think you'll have to use AUTOLOAD or some module that provides that functionality.