in reply to Help with perl error message

You marked the wrong line.

The problem is the print statement on the NEXT line, where you have

print OUT, @output;
That should be:
print OUT @output;
Sometimes perl misreports error line numbers, but I don't think it would get this one wrong; you may want to double-check.
--
Mike