B
Bill
while ( <INPUT1> ) {
# print "Reading $ARGV[0]\n";
print OUTPUT $_;
}
The copy statment, copy("file1","file2") or die "Copy failed: $!"; is
supposed to replace the above while statement.
I get this error with the copy statment ...
C:\PERL1\OUTPUT7>bbbb5.pl output5.txt output6.txt output7.txt
Undefined subroutine &main::copy called at C:\PERL1\OUTPUT7\bbbb5.pl line
24.
This is the script code ...
open (INPUT1, "$ARGV[0]") or die "Cannot open $ARGV[0]";
open (OUTPUT, "> $ARGV[2]");
#print "First input file is: $ARGV[0]\n";
#print "Second input file is: $ARGV[1]\n";
#print "The output file is: $ARGV[2]\n\n";
# This half of the code dumps everything in 'file1' to the output 'file3'
# while ( <INPUT1> ) {
# print "Reading $ARGV[0]\n";
# print OUTPUT $_;
# }
File :: COPY;
copy("$ARGV[0]","$ARGV[2]") or die "Copy failed: $!";
# This half of the code compares 'file2' to 'file1' and writes out
# any line that doesn't match to the output 'file3'
open (INPUT1, "$ARGV[1]") or die "Cannot open $ARGV[1]";
while ( <INPUT1> ) {
$match = 0;
$a = $_;
open (INPUT2, "$ARGV[0]") or die "Cannot open $ARGV[0]";
while ( <INPUT2> ) {
$b = $_;
if ($a eq $b) {
$match = 1;
last;
}
}
if ($match == 0) {
print OUTPUT $a;
}
}
# print "Reading $ARGV[0]\n";
print OUTPUT $_;
}
The copy statment, copy("file1","file2") or die "Copy failed: $!"; is
supposed to replace the above while statement.
I get this error with the copy statment ...
C:\PERL1\OUTPUT7>bbbb5.pl output5.txt output6.txt output7.txt
Undefined subroutine &main::copy called at C:\PERL1\OUTPUT7\bbbb5.pl line
24.
This is the script code ...
open (INPUT1, "$ARGV[0]") or die "Cannot open $ARGV[0]";
open (OUTPUT, "> $ARGV[2]");
#print "First input file is: $ARGV[0]\n";
#print "Second input file is: $ARGV[1]\n";
#print "The output file is: $ARGV[2]\n\n";
# This half of the code dumps everything in 'file1' to the output 'file3'
# while ( <INPUT1> ) {
# print "Reading $ARGV[0]\n";
# print OUTPUT $_;
# }
File :: COPY;
copy("$ARGV[0]","$ARGV[2]") or die "Copy failed: $!";
# This half of the code compares 'file2' to 'file1' and writes out
# any line that doesn't match to the output 'file3'
open (INPUT1, "$ARGV[1]") or die "Cannot open $ARGV[1]";
while ( <INPUT1> ) {
$match = 0;
$a = $_;
open (INPUT2, "$ARGV[0]") or die "Cannot open $ARGV[0]";
while ( <INPUT2> ) {
$b = $_;
if ($a eq $b) {
$match = 1;
last;
}
}
if ($match == 0) {
print OUTPUT $a;
}
}