E
elhombre
The following code attempts to create a report of any line created by diff
in the format nnnannn, 10c10, 10a11 etc. However perl complains about
"write() on unopened filehandle OUTPUT ", however I'm not writing to the
filehandle, I'm trying to write to the defined format which I understand has
its own namespace?
I'm not using STDOUT for this section as that is used for the first part of
the report that lists the file sizes, number of words etc.
Any hints?
Thanks in advance.
use English;
#Check that the correct number of arguments are passed to the interpreter
if($#ARGV != 1) {
print "usage : levelA.pl file1 file2";
exit;
}
system("diff -l -w $ARGV[0] $ARGV[1] > output.txt"); #For *nix
#now report the lines that are different
open(OUTPUT_FILE, "output.txt") or die "File $_ does not exist";
my $FORMAT_NAME = "OUTPUT";
my $FORMAT_TOP_NAME = "OUTPUT_TOP";
while (our $ln = <OUTPUT_FILE>) {
if($ln =~ m/^[0-9]*[a c][0-9]*/) {
write OUTPUT;
}
}
format OUTPUT_TOP =
line
------------------------------------------------
..
format OUTPUT =
@<<<<<<<<<<<<<<<<<<<<<<<<
our $ln
..
in the format nnnannn, 10c10, 10a11 etc. However perl complains about
"write() on unopened filehandle OUTPUT ", however I'm not writing to the
filehandle, I'm trying to write to the defined format which I understand has
its own namespace?
I'm not using STDOUT for this section as that is used for the first part of
the report that lists the file sizes, number of words etc.
Any hints?
Thanks in advance.
use English;
#Check that the correct number of arguments are passed to the interpreter
if($#ARGV != 1) {
print "usage : levelA.pl file1 file2";
exit;
}
system("diff -l -w $ARGV[0] $ARGV[1] > output.txt"); #For *nix
#now report the lines that are different
open(OUTPUT_FILE, "output.txt") or die "File $_ does not exist";
my $FORMAT_NAME = "OUTPUT";
my $FORMAT_TOP_NAME = "OUTPUT_TOP";
while (our $ln = <OUTPUT_FILE>) {
if($ln =~ m/^[0-9]*[a c][0-9]*/) {
write OUTPUT;
}
}
format OUTPUT_TOP =
line
------------------------------------------------
..
format OUTPUT =
@<<<<<<<<<<<<<<<<<<<<<<<<
our $ln
..