Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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]
[Your Mother]: Bill Clinton assaulted and raped repeatedly. Even when it was hinted and finally all but proved, no one cared because his sexism, and racism, and killing was decorous.
[Your Mother]: I think Trump might be better specifically because no one respects him so he won't get his way the way the others did.
[Your Mother]: (I certainly did not vote for him and have been an outspoken critic of his for three decades, by the by.)
[erix]: I'd like Russia threatened a bit more, flattered a bit less
[Your Mother]: The last two regimes killed a million, displaced 10 million, torture prisons, and ruined countries… somehow it's magically bad _now_.
[erix]: what/who are the last two regimes?
[Your Mother]: Bush/Obama. 15 straight years of warfare, torture, etc, etc.
[Your Mother]: All caused by the political fallout of Carter/Reagan when the Afghan chickens came home to roost on 9/11.
[Your Mother]: US foreign policy is toxic and like a broken record.

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-01-20 01:07 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (173 votes). Check out past polls.