in reply to modifying sub routine behaviour

Here's an implementation based on AUTOLOAD:
use strict; use vars q{$AUTOLOAD}; dostuff("One"); dostuff2("Two"); sub AUTOLOAD { no strict "refs"; print "Entering sub $AUTOLOAD.\n"; my $sub=join "::_", split /::/,$AUTOLOAD; &$sub(@_); print "Exiting sub $AUTOLOAD.\n"; } sub _dostuff { print "We're in dostuff: @_.\n"; } sub _dostuff2 { print "We're in dostuff2: @_.\n"; } __END__ Entering sub main::dostuff. We're in dostuff: One. Exiting sub main::dostuff. Entering sub main::dostuff2. We're in dostuff2: Two. Exiting sub main::dostuff2.
You prepend an underscore to your actual subroutine names, call them by their 'normal' names and have AUTOLOAD add the diagnostic prints and call the underscored versions.

Note that, although this implementation works, it is probably not the most efficient, as the entire AUTOLOAD system is expensive. But it's the best I could come up with for now. Other people will probably come up with better ways (and probably have in the time it took me to type this :) ).

CU
Robartes-