I use Data::Dumper a lot when debugging applications that return complex data structures. However I'm not always happy with the pretty printing that Data::Dumper provides and I often find myself copying he structure into Emacs and running perltidy against it.
As such I thought that it would be nice to have a Data::Dumper::Perltidy module that would do both steps in one go. I didn't find such a module on CPAN so I wrote one.
John.
--
If you do
local $Data::Dumper::Indent = 1;
it will indent things in a regular way, not the ugly default way (described as "fancy" in the docs).
I was aware of it.
From the Pod of the above module: "Data::Dumper also provides a certain level of pretty printing via the $Data::Dumper::Indent variable but it isn't quite as nice as the Perl::Tidy output".
In particular, it doesn't do any hash element alignment on => which I find helpful when debugging.
John.
--
Did you try Data::Dump
jand on 2009-01-30T18:26:31
It was also written out of frustration with the formatting of Data::Dumper (it does alignment on => too).Re:Did you try Data::Dump
jmcnamara on 2009-01-30T19:27:10
it does alignment on => too
Does it? I tried a few examples, including the one in the docs above, and it doesn't seem to.
Anyway, I guess the point is that while there are several modules that dump data structures effectively (at least for my needs) there is only one module that does the pretty printing the way I want it (at times when I do want it) and that is Perl::Tidy. That is really what I was aiming for.
:-) John.
--
Re:Did you try Data::Dump
jand on 2009-01-30T19:35:41
Does it? I tried a few examples, including the one in the docs above, and it doesn't seem to.Don't know. I only tried the simple test below, and it did align the => signs nicely. Maybe you are talking about something else:
perl -MData::Dump -we "dd \%INC"
Re:Did you try Data::Dump
bart on 2009-01-31T14:55:19
it does alignment on
=>
tooDoes it? I tried a few examples, including the one in the docs above, and it doesn't seem to.
There's also Data::Dump::Streamer, which does do alignment on
=>
by default.The problem that I personally have with this module, is that I find its indentation levels are far too deep, it really sucks if your window is not 200 character wide.
You have to choose between this level of indentation, or no indentation at all.