http://www.perlmonks.org?node_id=548192


in reply to parallel reading

azaria

If you're on a *nix box, you could use the paste command, e.g.:

paste A B C
But since you asked on perlmonks, you could try something like this (terrible) program:

#!/usr/bin/perl -w use strict; use warnings; open(A,"<A") or die "Can't open A!"; open(B,"<B") or die "Can't open B!"; open(C,"<C") or die "Can't open C!"; my @a = <A>; my @b = <B>; my @c = <C>; while (1) { my $fl=0; my $aa = shift @a || ""; my $bb = shift @b || ""; my $cc = shift @c || ""; chomp $aa; chomp $bb; chomp $cc; print $aa, $bb, $cc, "\n"; next if $#a + $#b + $#c; last; }
--roboticus