Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: I usually debug via...

by legato (Monk)
on Mar 03, 2005 at 00:04 UTC ( #436041=note: print w/replies, xml ) Need Help??

in reply to I usually debug via...

While I use ptkdb for tracing, I also use the indispensible Data::Dumper::Simple0. Combining the latter with a global $_DEBUG allows me to do this:

use strict; use warnings; #... blah if ($_DEBUG) { require Data::Dumper::Simple; Data::Dumper::Simple->import; } sub _explain (@_); # ... some code $record = $sth->fetchrow_arrayref; _explain $record; # ... some code sub _explain (@_) { return undef unless $_DEBUG; local $|=1; my @call = caller(1); print '#- in ',$call[3],' ',Dumper($_),"\n" for (@_); }
This results in:
#- in mySub $record = [ 'aUser', 'aPassword' ]

I usually use STDOUT so I can redirect to a log file if I wish, but sometimes I call out to a logger module, too. One of the advantages of this is that I can set $_DEBUG in-code or with a command-line option &c., thereby controlling the verbosity level on a per-run basis.

0: I use this instead of Data::Dumper simply because it automagically prints the actual name of the variable instead of $VAR1 and the like. It's possible to do that with the Data::Dumper module, too, but the ::Simple version does it anyhow, so why reinvent that wheel?

Anima Legato
.oO all things connect through the motion of the mind

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://436041]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2018-01-16 23:28 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (193 votes). Check out past polls.