I'm trying to print some parse trees, and Data::Dumper
is very verbose for that, for example printing:
{
'A' => {
'ID' => 'y'
},
'OP' => '=',
'B' => {
'NUM' => '5'
}
},
rather than let's say:
{
'A' => {'ID' => 'y'},
'OP' => '=',
'B' => {'NUM' => '5'}
},
and it's very hard to read since it take massive number of lines.
Is there any Perl library which does what Data::Dumper
does except more tersely, or do I need to write my own?
You want
Data::Dump
:Data::Printer
is a more modern alternative with colored output.You mean besides Data::Dumper::Concise? :)
If using
$Data::Dumper::Indent
is not enough, you may like to try JSON or YAML module families, if you only need data to be human-readable (i.e. for debugging). Their format is close enough to Perl's own to read easily and they have many formatting options.