open(IN, "$ARGV[0]") || die "unable to open $ARGV[0]"; open(OUT, ">$ARGV[1]") || die "unable to open $ARGV[0]"; binmode(OUT); #set output mode as binary while() { if(/^\n$/) { print OUT "\r\n"; # if this the record separator, print a proper line } else { print OUT; } # else just print line with a CR } close(IN); close(OUT);