{ package Before; sub new { my ($sClass,$f) = @_; my $fBefore= sub { print "Special stuff for class $sClass\n"; goto &$f }; return bless($fBefore,$sClass); } } { package AlsoBefore; our @ISA=qw(Before); } my $f1=Before->new(sub {print "Hello world!\n"}); my $f2=Before->new(sub {print "Bonjour, le monde!\n"}); my $f3=Before->new(sub {print "Guten tag, die welt!\n"}); my $f4=AlsoBefore->new(sub {print "Boker tov, olam!\n"}); $f1->(); $f2->(); $f3->(); $f4->();