strip the carriage retrun (fwd)

MegaZone (megazone@livingston.com)
Wed, 23 Oct 1996 15:16:19 -0700 (PDT)

Once upon a time alexm@agetech.net shaped the electrons to say...
>Does anyone have a nifty little program that will strip the dos carriage
>retruns when importing to Linux?

#!/usr/local/bin/perl
# m2j - turn ^M to ^J to convert PC files to a form pleasing unto UNIX
#To turn ^M to ^J in all the files under foo, do
#find foo -type f -print | xargs m2j
# Author: 96/6/18 Carl Rigney cdr@livingston.com

for $FILE (@ARGV) {
$FILEBAK = $FILE.'.bak';
rename($FILE,$FILEBAK) || die "$0: unable to rename $FILE to $FILEBAK; $!\n";
open(FILEOLD,'<'.$FILEBAK) || die "$0: unable to read $FILEBAK; $!\n";
open(FILENEW,'>'.$FILE) || die "$0: unable to write to $FILE; $!\n";
while (<FILEOLD>) {
s/\015/\012/g;
print FILENEW $_;
}
close(FILEOLD);
close(FILENEW);
}