So it seems like every time write a script that reads and writes to a file I get this error:
print() on closed filehandle DATA_1 at compare_names.pl line 33, <SECO +ND> line 773874
The error above is specific for the code below, but none the less it's telling me the same thing. If you have any ideas on how to stop the compiler from yelling at me all the time I would greatly appreciate it! Thank you very much!
#! usr/bin/perl -w use strict; use warnings; print "What is the filepath of Jay's file?\n"; my $first_file = <STDIN>; print "And the mine?\n"; my $second_file = <STDIN>; open FIRST, $first_file; open SECOND, $second_file; open DATA_1, "</home/Alan/Desktop/sequence_data/sequence_comparison/Ja +ys_unique.txt"; #open DATA_2, "/home/Alan/Desktop/sequence_data/sequence_comparison/my +_unique_results.txt"; while(<FIRST>){ my $name_1 = $_; my $match = 0; while(<SECOND>){ my $name_2 = $_; if($name_1 eq $name_2){ $match = 1; last; } } if($match != 1){ print DATA_1 $name_1,"\n"; } } close FIRST; close SECOND; close DATA_1;
In reply to print() on Closed File Handle Error! by twaddlac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |