http://www.perlmonks.org?node_id=431051


in reply to I usually debug via...

I'm a printer.

Long ago I put these two lines at the bottom of a script; nowadays I always throw them into my exception handling modules, but push them to main::.

sub ::D { require Data::Dumper; $Data::Dumper::Indent += 0; local $Dat +a::Dumper::Indent = 1; Data::Dumper::Dumper(@_) } sub ::DD { require Carp; Carp::confess(::D(@_)) } # Then from anywhere, use it like this: print ::D({ state => $some_obj }); [...] ::DD($obj) if $bugs_exist;

(The += 0 is just a stupid warning silencer.)

Replies are listed 'Best First'.
Re^2: I usually debug via...
by chime (Friar) on Feb 15, 2005 at 10:23 UTC

    I debug my code with print,
    my mind with alcohol,
    and my dog with flea powder

      chime~

      So close to a haiku....

      debug code with print
      a mind using alcohol
      dogs with flea powder

      Boots
      ---
      If you are not going to go 95, just avoid our state. Please.
      -Ian Sulam
        But it's still not a haiku (at least to my limited understanding) because it's not about a seasonal event, and his original form, I feel, reads much more poetically. What is with this obsession of things that look similar to haikus? Is it just that they appear easy to create and everyone wants to be a poet?

        Heres one I made earlier on the same theme

        Bug haiku

Re^2: I usually debug via...
by RolandGunslinger (Curate) on Feb 22, 2005 at 15:14 UTC
    print and perl -d for me between these two I get my debugging done oh, and heavy use of Data::Dumper