#!/usr/bin/perl -w use strict; use Text::Tabs; use Symbol; #Symbol and my @data; #array instead of hash so the same file can be in several columns my $sep =''; if( $ARGV[0] =~ /^-sep/ ){ (undef, $sep, @ARGV) = @ARGV; } die("usage: lam [-sep seperator] file1 file2 [...]\n") unless scalar @ARGV >1; for(my $i=0; $i < scalar @ARGV; $i++){ open($data[$i]->{FH}=gensym, $ARGV[$i]); $data[$i]->{w}=0; while(readline(*{$data[$i]->{FH}})){ my $length = length(expand($_)); $data[$i]->{w} = $length > $data[$i]->{w} ? $length : $data[$i]->{w}; } $data[$i]->{h} = $.; seek($data[$i]->{FH}, 0, 0); } my $max = (sort {$main::b <=> $main::a} map {$_->{h}} @data)[0]; for(my $j=0; $j<$max; $j++){ for(my $i=0; $i < scalar @ARGV; $i++){ if( $j > $data[$i]->{h} ){ print ' 'x$data[$i]->{w}; } else{ chomp($_ = readline(*{$data[$i]->{FH}})); $_ = expand($_); print $_, ' 'x($data[$i]->{w}-1-length); } print $sep unless $i+1 == scalar @ARGV; } print "\n"; }