package Foo; use strict; sub new{ return bless {}, shift; } sub foo{ my $self = shift; print "Foo called\n"; } sub bar{ my $self = shift; print "Bar called\n"; my $code = "\$self->foo()"; # it won't work withouth the "\" eval $code; } 1;