How can I use perl debuggers pretty print for a hash in normal program code?

1.9k Views Asked by At

In Perl debugger you can very nice output a hash like:

  DB<1> x \%my_hash

How can I use the debugger output method 'x' in my programm to log pretty formated hash data in my logfile?

1

There are 1 best solutions below

2
On BEST ANSWER

Use Data::Dumper. It is a core module, so no installation required. It is a good debugging tool.

use Data::Dumper;

...

print Dumper \%my_hash;