http://www.perlmonks.org?node_id=1064323


in reply to error on file open

Change your open (and following) line to:

open my $PS17, '<', $FILENAME or die "$! error on open - $FILENAME"; read_and_write ($PS17);

That doesn't fix the problem, but it gives better diagnostics (you know what was being opened), avoids potential problems with some file names by making the open mode explicit, and better manages the lifetime of the file handle. You'll need to update read_and_write to take the file handle as a parameter.

True laziness is hard work