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!

4 Comments

The one-liner is too long for the content column width. It gets truncated. I used "View Source" to read the rest of it.

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](http://blogs.perl.org/users/ovid/2010/06/better-dump-output-in-debugger.html).

Leave a comment

About Steven Haryanto

user-pic A programmer (mostly Perl 5 nowadays).