in reply to How do I append more than one files?
This script does something like what you want:
#!perl -w =head1 USAGE ./combine.pl output_file input_1 input_2 [..., input_x] Where output_file is the file to which all input files (input_1, input_2, ..., input_x) should be combined to. =cut use strict; my $out = shift @ARGV; open( my $out_fh, '>', $out ) or die("Could not open output file '$out': $!\n"); for my $file (@ARGV) { open( my $in_fh, '<', $file ) or die("Error opening '$file': $!\n"); print $out_fh $_ while (<$in_fh>); close($in_fh) or die("Error closing '$file': $!\n"); print $out_fh "\n"; } close($out_fh) or die("Error closing '$out': $!\n");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I append more than one files?
by Anonymous Monk on Jun 16, 2004 at 23:50 UTC | |
by saskaqueer (Friar) on Jun 17, 2004 at 00:12 UTC |