<?xml version="1.0" encoding="windows-1252"?>
<node id="998828" title="Re: Challenge: Dumping trees." created="2012-10-13 05:13:17" updated="2012-10-13 05:13:17">
<type id="11">
note</type>
<author id="45414">
jmcnamara</author>
<data>
<field name="doctext">
&lt;p&gt;
One option may be [http://search.cpan.org/~jmcnamara/Data-Dumper-Perltidy-0.02/lib/Data/Dumper/Perltidy.pm|Data::Dumper::Perltidy]:
&lt;/p&gt;

&lt;code&gt;
    #!/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__


&lt;/code&gt;

&lt;p&gt;
Which gives a structure similar to your hand manipulated example:
&lt;/p&gt;
&lt;spoiler&gt;
&lt;code&gt;
    $VAR1 = [
        [
            [
                [
                    [
                        [
                            [
                                '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'
        ]
    ];
&lt;/code&gt;
 &lt;/spoiler&gt;
&lt;p&gt;
The perltidy options are explained in the [http://perltidy.sourceforge.net/perltidy.html|Perltidy manpage].
&lt;/p&gt;
&lt;p&gt;Update: actually this isn't much of an improvement over the base Data::Dumper formatting due to the &lt;tt&gt;-boc&lt;/tt&gt; option but without it Perl::Tidy compacts the branches too much. So, it probably isn't useful in this case.
&lt;/p&gt;
&lt;p&gt;
--
&lt;br&gt;
John.
&lt;br&gt;</field>
<field name="root_node">
998803</field>
<field name="parent_node">
998803</field>
</data>
</node>
