package MyPack; use strict; sub new($$) { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = { }; bless($self, $class); return $self; } sub foo($) { my $self = shift; print "foo is unmodified.\n"; } sub changeFoo($) { my $line; my $code; while ($line = ) { $code .= $line; } eval $code; } 1; __DATA__ sub foo($) { my $self = shift; print "foo has been modified.\n"; }