Some files (often created under DOS/Windoze) have a ^M on the end of the line. This is okay under DOS/Windows but it is an ugly pain under a real OS (such as FreeBSD).
To remove the ^M for a directory of files you can use the following script:
perl -pi -e "s/r//g"
It works a treat.