Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've got a CGI webapp that is starting to grow

Right now it has some elementary debugging support--
sub x{ my ($self)= @_; DEBUG_FUNCTION_NAME && MyDebugger::log_function_name( $self ); }
MyDebugger::log_function_name does all the necessary operations on caller(1) to get me the info I need.
I know some of the CPAN developer packagers have figured out ways to hook into a function as it is called. unfortunately, I haven't been able to reverse engineer how to do it
Does anyone know if its possible for me to do this in perl itself (without using xs ) : to have a specific function called per sub call ?

Replies are listed 'Best First'.
Re: Logging functions as they are called
by dave0 (Friar) on Sep 21, 2006 at 18:52 UTC
    Take a look at Devel::CallTrace -- it's probably the simplest of the call-tracing modules.
Re: Logging functions as they are called
by dtr (Scribe) on Sep 21, 2006 at 18:52 UTC

    Have a look at Sub::WrapPackages, or Hook::LexWrap. These should both help with what you're trying to do.

    Also, if you're getting into logging, you could do much worse than looking at Log::Log4perl too.

Re: Logging functions as they are called
by traveler (Parson) on Sep 21, 2006 at 21:28 UTC
    Try Aspect::Trace. It sounds like exactly what you are looking for.
Re: Logging functions as they are called
by eff_i_g (Curate) on Sep 21, 2006 at 21:29 UTC