#! perl -slw use strict; my @files = @ARGV; my @fhs; my $i = 0; open $fhs[ $i++ ], '<', $_ or die "$_ : $!" for @files; #while( my @lines = map{ scalar <$_> || () } @fhs ) { !!Bad code!! while( ## Build an array of one line (or the null string) from each file. my @lines = map{ defined( my $line =<$_> ) ? $line : '' } @fhs ) { chomp @lines; ## Remove the newlines print join ' ', @lines; ## and concatenate them. } close $_ for @fhs; __END__ P:\test>465737 test1.dat test2.dat test3.dat file1 line 1 file2 line 1 file3 line 1 file1 line 2 file2 line 2 file3 line 2 file1 line 3 file2 line 3 file3 line 3 file1 line 4 file2 line 4 file3 line 4 ...