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

I'm a newbie, so this question may be obvious and/or poorly formed. Is it possible to set Data::Dumper in some manner in order to look at all variables enclosed? Something akin to --
use Data::Dumper; # enable monitoring my $rc = foo(1, 2, 3); # disable monitoring sub foo { my ($one, $two, $three) = @_; my ($i, $j); # manipulate $i & $j... return $j; }
Is there some way to set this up such that values of $rc & $i are printed out? Thanks.

Replies are listed 'Best First'.
Re: using Data::Dumper to monitor methods?
by saintmike (Vicar) on Mar 01, 2005 at 01:14 UTC
    Seems like you're aiming in the general direction of tracing. If you start your program with tracing enabled, via
    PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=31" perl -dS yourscript.pl
    then perl's debugger will (non-interactively) start logging each line executed and will also show input/output parameters of functions called.

    Generally, though, I'd recommend using a logging framework like Log::Log4perl for this instead. Once embedded in the code, it can be switched on or off via a configuration file. It's easier to adapt to you your specific needs.

Re: using Data::Dumper to monitor methods?
by Anonymous Monk on Mar 01, 2005 at 00:57 UTC
    Rearticulating my question, is there a way to look at the values of temporal variables within a function without modifying the code? Thanks.

      You're probably wanting to look at the perl debugger, DB. How precisely to do that I leave to the more experienced/adventurous, but I'm quite sure that the perl debugger can do this somehow.