4 ms·
Here's what I could find on the page: Supplied with a data structure, returns a data structure with the complicated bits summarised. Every attempt is made to p
by equalunique 9y ago
Here's what I could find on the page:
Supplied with a data structure, returns a data structure with the complicated bits summarised. Every attempt is made to preserve those parts of the data structure that don't need summarising.
Structures are only summarised if (1) they're blessed objects, (2) they're not the root structure passed to tersify (so if you actually to want to dump a complex DBIx::Class object, for instance, you still can), and (3) a plugin has been registered that groks that type of object.
Summaries are blessed scalars of the form "Classname (refaddr) summary", e.g. "DateTime (0xdeadbeef) 2017-08-15".
- kbenson 9y agoEven after installing the DateTime plugin for it, it's not tersifying for me. I'm not sure if it's me using it incorrectly, or if it's not working for some other reason[1]. That said, I see promise with this. I use Data::Dump with a custom handler to make dumping of DateTime and specific DBIC subclass objects much more palatable based on whether the current item being recursed's ISA. e.g. 'sprintf "%s [%s]", $_[1], $_[1]->time_zone->name' for DateTime objects. Having that abstracted away into a module with plugins would simplify that quite a bit. 1: Non-working tersification: # perl -E 'use strict; use warnings; use Data::Dumper; use Data::Tersify qw(tersify); use Data::Tersify::Plugin::DateTime; use DateTime; my $dt = DateTime->now; say "### RAW ###"; say $dt; say "\n\n### DUMPER ###"; say Dumper($dt); say "\n\n### TERSIFIED ###"; say Dumper(tersify($dt));'
- davecardwell 9y agoThe Data::Tersify documentation mentions that it only summarizes if the object is “not the root structure passed to tersify (so if you actually to want to dump a complex DBIx::Class object, for instance, you still can)”. So instead of… Dumper(tersify($dt)) You would want to try… Dumper(tersify({ now => $dt }))
- kbenson 9y agoAh, that explains it. I had noticed that's how they specified it in Data::Tersify::Plugin::DateTime, but had missed that note. I'm not sure the reasoning behind that behavior. Presumably if you don't want it tersified, you don't pass it to tersify, and just pass it to your dumper function directly.