my $string = <<'STRING'; package Foo; sub new { bless [] => shift } sub foo { print "foo!\n" } STRING eval $string; my $foo = Foo->new; $foo->foo;