I was just going to mention that "%-20s" is probably more what was wanted than "%20s" (yes, annoying how printf defaults to right-justifaction for non-numeric formats). Then I noticed no double underlines and that you assume that all of the arrays have the same number of elements. Finally, I went with "%-19s" which fits nicely on screens that are a multiple of 20 characters wide.
- tye (but my friends call me "Tye")my @keys= sort keys %TOP; my $format= join( " ", ("%-19s") x @keys ) . "\n"; printf $format, @keys; printf $format, map { "=" x length($_) } @keys; my $line= 0; while( grep { $line <= $#{$TOP{$_}} } @keys ) { printf $format, map { def($TOP{$_}[$line]) } @keys; $line++; } sub def { return defined $_[0] ? $_[0] : def($_[1],""); }
In reply to (tye)Re: Structured Printing of Hash of Arrays
by tye
in thread Structured Printing of Hash of Arrays
by Limo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |