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


in reply to Conversion of unix LF to DOS LF issues

You didn't specify on which system the script is running.

As a bonus, here are more universal versions:

Update: Cleaned up my booboos.