I was tempted to call this a 'debugging trick of the week' but my last one was nearly 2 months ago :)

Basically the problem I had was in a CGI script I wanted to know what page was being displayed and if any utility subs were being used. I was just about to go through and add some debugging prints to the the top of each sub when I deicided that I had to be able to be lazy...

# turn on debugging use constant DEBUG_HOOKS => 0; if (DEBUG_HOOKS) { require Hook::WrapSub; require Devel::GetSymbols; require Data::Dump; no warnings 'once'; my $hook_pre = sub { printf "<hr><pre>Calling: <b>%s</b>\nArgs: %s</pre><hr>", $Hook::WrapSub::name, Data::Dump::dump(@_); }; my $hook_post = sub { printf "<hr><pre>Called: <b>%s</b> Result: %s</pre><hr>", $Hook::WrapSub::name, Data::Dump::dump(@Hook::WrapSub::result); }; foreach my $sub (grep /^(page|do)_/, Devel::GetSymbols::subs()) { Hook::WrapSub::wrap_subs($hook_pre, $sub, $hook_post); } }
Replace Data::Dump with your favorite (I prefer it as it is compact) and the grep to match your naming conventions.