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

There are a lot of different ways to encode file newlines. DOS uses "\r\n", Unix uses just "\n" and some Mac files use just "\r".

I normally want them Unix style, and created a simple script to solve this problem. It is really simple, but really useful. It works both for DOS and Mac files very well.

Update: Sorry but the missing parenthesis are important.

#!/usr/bin/perl -pi s/(\012?\r|\r?\012)/\012/g;