}
###########################################################################
-sub printTree
+sub warningsTree
{
my $tre = shift ;
my $prefix = shift ;
my $max = (sort {$a <=> $b} map { length $_ } keys %$tre)[-1] ;
my @keys = sort keys %$tre ;
+ my $rv = '';
+
while ($k = shift @keys) {
$v = $tre->{$k};
die "Value associated with key '$k' is not an ARRAY reference"
my $offset ;
if ($tre ne $tree) {
- print $prefix . "|\n" ;
- print $prefix . "+- $k" ;
+ $rv .= $prefix . "|\n" ;
+ $rv .= $prefix . "+- $k" ;
$offset = ' ' x ($max + 4) ;
}
else {
- print $prefix . "$k" ;
+ $rv .= $prefix . "$k" ;
$offset = ' ' x ($max + 1) ;
}
if (ref $rest)
{
my $bar = @keys ? "|" : " ";
- print " -" . "-" x ($max - length $k ) . "+\n" ;
- printTree ($rest, $prefix . $bar . $offset )
+ $rv .= " -" . "-" x ($max - length $k ) . "+\n" ;
+ $rv .= warningsTree ($rest, $prefix . $bar . $offset )
}
else
- { print "\n" }
+ { $rv .= "\n" }
}
+ return $rv;
}
###########################################################################
if (@ARGV && $ARGV[0] eq "tree")
{
- printTree($tree, " ") ;
+ print warningsTree($tree, " ") ;
exit ;
}
last if /=for warnings.pl begin/;
}
print "\n";
- printTree($tree, " ") ;
+ print warningsTree($tree, " ") ;
print "\n";
while(<$oldlexwarn>) {
last if /=for warnings.pl end/;