Custom dumping *in* Data::Dump
After blogging about my small patch to Data::Dump, I contacted Gisle Aas. He is quite responsive and finally comes up with a new release (1.16) of Data::Dump containing the cool new filter feature. My previous example after converted to use the new feature becomes:
$ perl -MData::Dump=dumpf -MDateTime -e'dumpf(DateTime->now, sub { my ($ctx, $oref) = @_; return unless $ctx->class eq "DateTime"; {dump=>qq([$oref])} })' [2010-06-09T12:22:58]
This filter mechanism is quite generic and allows you to do some other tricks like switching classes, adding comments, and ignore/hide hash keys. The interface is also pleasant to work with, although starting with this release the "no OO interface" motto should perhaps be changed to "just a little bit of OO interface" :-)
Aren't we glad that stable and established modules like this are still actively maintained and getting new features.
Thanks, Gisle!
The one-liner is too long for the content column width. It gets truncated. I used "View Source" to read the rest of it.
@masak: Yeah, the CSS on blogs.perl.org for the "pre" element apparently needs to be modified somewhat (e.g. showing a scrolling bar).
You can also disable CSS on your browser (e.g. shift-G in Opera, or Alt-V, Y, N in English Firefox).
That's very cool. I've often wanted to filter the contents of deep dumps and I can envision use cases for changing the dump representation as well. Great idea, Steven!
Thanks for this. [I've now integrated this into my debugger configuration](https://blogs.perl.org/users/ovid/2010/06/better-dump-output-in-debugger.html).