Bryan Harris wrote:
> I'm interested in doing the equivalent of a horizontal "cat" on a
> bunch of files. That is, instead of listing them one after another,
> I'd like them "cat"ted next to each other horizontally (tab
> separated).
Hi Bryan.
This seemed kinda neat. Thanks to David for the data :)
use strict;
use warnings;
local @ARGV = qw( file1.txt file2.txt file3.txt );
my @fds;
foreach (@ARGV) {
open (my $fd, $_) or die $!;
push (@fds, $fd);
}
my @line;
do {
undef @line;
FILE:
for (@fds){
for (scalar <$_>) {
next FILE unless defined;
push @line, split (' ', $_);
}
}
print join("\t", @line), "\n";
} while @line;
close foreach @ARGV;
output:
file1 line1 file2 line1 file3 line1
file1 line2 longer than usual file2 line2
file1 line3 shorter file2 line3
file2 line4
file2 line5
Cheers,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]