Monday, September 10, 2007

Perl Error: Maybe you didn't strip carriage returns after a network transfer?

I am very much new to Perl; I have downloaded a Perl script from the net and when I tried to run it, I was getting the below error message:
Maybe you didn't strip carriage returns after a network transfer?
Did you ever face this problem?
I searched the net and found a solution, it's because of the new line characters added after downloading the script.

Run the below commands on the command line to make your script work.
$perl -pi.bak -e 's/\r\n/\n/g' myfile.pl
$perl -pi.bak2 -e 's/\r/\n/g' myfile.pl
This will take the back up of the myfile.pl and will replace both Mac End Of Lines and MS End Of Lines into Unix like ones.