Like many people I've used the Perl module Data::Dumper for years and been reasonably happy with the output. Generally I want the output rolled up into the smallest (line-wise) output and Data::Dumper allows this. However, I use Math::FixedPrecision quite a bit in this project and as it is a blessed object the fixed precision numbers of 2 come out ridiculously verbose and almost unreadable.
Recently I saw a blog or reference to Data::Dump. I decided to try it and find the output better although a) the output is over multiple lines when I'd prefer the smallest amount of lines (achievable with Data::Dumper's Indent setting) and b) it suffered with the same issue with Math::FixedPrecision. However, Data::Dump also has Data::Dump::Filtered and this allows me to add a sub which filters the output and hence I can turn the rather verbose object output for Math::FixedPrecision with precision 2 into a simple string "11.01" with a simple filter like:
I've added filters for other objects too in some of my code to avoid printing the entire object like this:
Now, if only I could get it to condense the output more to reduce the number of lines.
Comments
How about Data::Printer?
'Math::FixedPrecision' => sub { return "$_[0]" },
};
multiline => 0,
class => { expand => 0 },
filter => {
'Math::FixedPrecision' => sub { return "$_[0]" },
};
multiline => 0,
class => { expand => 0 },
filter => {
'Math::FixedPrecision' => sub { return "$_[0]" },
},
}
I'll try it out but omg, that is a long list of dependencies
I installed Data::Printer this morning and it took around 20 minutes to install and test all the dependencies including Moose. Compare Data::Printer dependencies and Data::Dump dependencies and you'll see what I mean.
I want something small and light and Data::Printer does not look like that but I'll give a try.
See also Data::Printer
Data::Printer
You should check out
Data::Printer