in reply to compare two files and print the differences of file 2 in a third file
Your problem is in this line:
while ( my $line = < GOODFILE> ) {
Try using printto see what you're getting in $line:
while ( my $line = < GOODFILE> ) { chomp $line; print "GOODFILE line: '$line'\n";
Your error should be clear to you if you do this.
In Section
Seekers of Perl Wisdom