Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: I usually debug via...

by ff (Hermit)
on Feb 17, 2005 at 05:20 UTC ( #431840=note: print w/ replies, xml ) Need Help??


in reply to Re^2: I usually debug via...
in thread I usually debug via...

Also along these lines, I like to use lines that start with if 0 and if 1 as additional debugging tools. I particularly use this approach with a little subroutine that invokes Dumper (I could probably do this directly, but anyway). Again, when I want the program to dump the object, it's easy to flip the '0' to '1', and when I'm done with the need to see such output, I can easily find all patterns of ^if 1 and flip the '1' back to '0'.

For example, my "main" script might contain the following:

use strict; require 'gen_subs.pl'; my $foo = { 'abc', 123, 'def', 456 }; gs::do_dumper( 'foo423:', $foo ) # 423 a silly, easy-to-find label if 0;

and a helper file/libary named 'gen_subs.pl' might contain:

package gs; use strict; use Data::Dumper; sub do_dumper { my ( $label, $variable ) = @_; my $msg = Dumper( $variable ); warn "$label:\n$msg\n"; }


Comment on Re^3: I usually debug via...
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://431840]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2015-07-03 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls