http://www.perlmonks.org?node_id=998828


in reply to Challenge: Dumping trees.

One option may be Data::Dumper::Perltidy:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper::Perltidy; $Data::Dumper::Perltidy::ARGV = '-i=4 -boc -nopro'; my $data = [ [ [[[[["a", "b"], "c"], ["d", "e"]], [[["f", "g"], "h"], [[" +i", "j"], ["k", ["l", "m"]]]]], ["n", [[["o", "p"], "q"], ["r", "s"]]]], ["t", ["u", "v"]] ], [["w", ["x", "y"]], "z"] ]; print Dumper $data; __END__

Which gives a structure similar to your hand manipulated example:

The perltidy options are explained in the Perltidy manpage.

Update: actually this isn't much of an improvement over the base Data::Dumper formatting due to the -boc option but without it Perl::Tidy compacts the branches too much. So, it probably isn't useful in this case.

--
John.