blob: 87290af7891c896d70d2624f8a7806979277f73d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/usr/bin/perl
use Data::Dumper;
my %width = ();
my @lines = ();
while (my $line = <>) {
chomp $line;
push @lines, $line;
my @parts = split(/\t/, $line);
my $counter = 0;
for (; $counter < @parts; $counter++) {
my $partlen = length($parts[$counter]);
$width{$counter} = $partlen if !defined($width{$counter}) or $partlen > $width{$counter}
}
}
for my $line (@lines) {
my @parts = split(/\t/, $line);
my $counter = 0;
for (; $counter < @parts; $counter++) {
my $partlen = $width{$counter};
printf "%-*s | ", $partlen, $parts[$counter];
}
printf "\n";
}
#print Dumper(\%width);
|