# Pretty() filters Data::Dumper output to join up short related lines. # This makes it a lot easier to read a typical hash structure. # Set $Data::Dumper::Fill like you would set $Text::Wrap::columns. # sub Pretty { my @src = split(/\n/, join('', @_)); my @dst = (); my $f = $Data::Dumper::Fill || 72; my $i = 0; while ($i <= $#src) { my $l = $src[$i]; if (not $l =~ /[\[\{\(]\s*$/) { push(@dst, $l); $i++; next; } my ($p) = ($l =~ /^(\s+)/); my $j = $i+1; while ($j <= $#src) { my $n = $src[$j]; my ($q) = ($n =~ /^(\s+)/); $n =~ s/^\s+/ /; if (length($l) + length($n) >= $f) { $l = $src[$i]; last; } $l .= $n; if ($q and $p and $q eq $p) { $i = $j; last; } $j++; } push(@dst, $l); $i++; } return join("\n", @dst) . "\n"; }