$ perl -MBefore -e 'my $foo = bless(sub { print shift()."\n" } => 'Before'); $foo->("foo"); $foo->("bar")' Stuff before foo Stuff before bar