summaryrefslogtreecommitdiffstats
path: root/column.pl
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2019-01-04 13:54:00 +0100
committerFlorian Pritz <bluewind@xinu.at>2019-01-04 13:54:00 +0100
commitd4b107f5035413bcf93f24a523a6f8b695ba6b92 (patch)
tree74f53d2c3cbf7d71264d1c9239d6af21f3038724 /column.pl
parentf2c64faeecf602c024b81fcc3760981e36de45f4 (diff)
downloadbin-d4b107f5035413bcf93f24a523a6f8b695ba6b92.tar.gz
bin-d4b107f5035413bcf93f24a523a6f8b695ba6b92.tar.xz
Add new scripts
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'column.pl')
-rw-r--r--column.pl27
1 files changed, 27 insertions, 0 deletions
diff --git a/column.pl b/column.pl
new file mode 100644
index 0000000..87290af
--- /dev/null
+++ b/column.pl
@@ -0,0 +1,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);