in reply to making 3 files into one
Update: We assume that each file has the same number of lines.use strict; open my $FILE1, '<', 'my/input/file1' or die "Could not open FILE1: $! +"; open my $FILE2, '<', 'my/input/file2' or die "Could not open FILE2: $! +"; open my $FILE3, '<', 'my/input/file3' or die "Could not open FILE3: $! +";; open my $FILE4, '>', 'my/output/file' or die "Could not open FILE4: $! +"; while (my $file1 = <$FILE1>) { my $file2 = <$FILE2>; my $file3 = <$FILE3>; chomp $file1; chomp $file2; print $FILE4, "$file1 $file2 $file3" or die "Could not print to FI +LE4"; }
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|