http://qs1969.pair.com?node_id=472367


in reply to Data::Dumper(::Simple) is your friend

Just lately I have come to depend on Data::Dumper a lot, particularly as I'm developing in a web environment where running a debugger is not practical.

I've come to often quickly add the following into a block of code:

{ use Data::Dumper; print( Dumper( \%hashvariable ) ); }
I put braces around just out of habit.

Note that I put the backslash in front of the hash reference, for some reason that results in a clearer-to-read output from Dumper than just Dumper( %hashvariable ).

When in a web environment (such as Mason) I use the following to dump my variables:

{ use Data::Dumper; $m->out( '<pre>' . Dumper( \%hashvariable ) . '</pre>' ); }

Replies are listed 'Best First'.
Re^2: Data::Dumper(::Simple) is your friend
by neniro (Priest) on Jul 05, 2005 at 07:56 UTC
    When I debug Webapplications I use Data::Dumper and CGI::Carp like this:
    use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; use Data::Dumper; # ... die Dumper $cgi;
      I hope you have some way of conditionally removing the CGI::Carp line in production. Otherwise anyone who finds a security hole can use it to debug their attack on your code. That can turn minor security breaches into big ones very, very quickly.

      Google for advice on SQL Injection attacks to see a practical example of how attackers can use this debugging information to make their job a lot easier.

Re^2: Data::Dumper(::Simple) is your friend
by cbrandtbuffalo (Deacon) on Jul 05, 2005 at 16:13 UTC
    We do a similar thing in our dev environment with Template::Toolkit. We have a flag that gets set automatically so all Template data structures get dumped at the bottom of the page when running in dev, but in QA and Prod it's turned off. It can be very useful when debugging strange data or param issues.