my $old_method; BEGIN { $old_method = CGI->can('header'); }; sub CGI::header { print "Before\n"; $old_method->(@_); print "After\n"; };