in reply to Re^2: Opening a File Twice
in thread Opening a File Twice

You might want to change
foreach (@files) {
to
foreach my $file (@files) {
Then you could replace
$outputfile = "STEP2_" . $_; open(OUTFILE, ">" , $outputfile) or die $!;
with
$outputfile = "STEP2_" . $file; open(OUTFILE, ">" , $outputfile) or die "opening $outputfile $!";
The value of $_ is almost certainly used for more than the name of the file being processed. These changes will guarantee the filename is retained, and associate the actual filename with the error.

Revise: The foreach was corrected, thanks to moritz kindly pointing out my gaffe.