in reply to Removing Carriage returns from text files

Ok, how 'bout
$x="hello\n\rWorld"; $k=chr(13); $x=~s/$k//g; print $x;

Replies are listed 'Best First'.
Re: Re: Removing Carriage returns from text files
by Kalimeister (Acolyte) on Oct 18, 2001 at 00:17 UTC
    That doesn't seem to work as when I run that on the file and then view it in UtraEdit's Hex mode chr(13) seems to be 0D which as far as I can tell is the offending character. So I tried chr(10) instead and it returns 0D 0A. When I was testing this in vb I found that I need to remove 0D and keep 0A. I tried s/\x0D//g but that didn't work, I tried s/\n/\012/g ditto. I tried all the possibilities but as far as I can tell in Windows \n means CR&LF no matter what you try.
    Am I totally off base here?
    Thanks again.
    Kalimeister
      Yeah - that does make sense :-(

      On MacPerl \n gets converted to \r on the fly - and the equivalent on a PC would be \r\n.

      I tried - but I'm out of ideas. Sorry.

      Well, if you've got UltraEdit, your problem is solved! Just open the file, select File->Conversions->Dos to Unix, and you're done.

      If you were looking for an automated way to do a bunch of files, please disregard this note...

      Are you sure your problem is within the file?

      UltraEdit is by default configured to 'Autodetect Unix files' and to 'Auto convert Unix files'.

      If this is happening, then your UltraEdit will pick up your correctly formatted file (with LF's only) and change all LF's to LF-CR's before showing it to you. When you use Ctrl-H to see it in hex, it is already converted back to DOS mode.

      Check Advanced-Configuration-General in your UltraEdit.

      f--k the world!!!!
      /dev/world has reached maximal mount count, check forced.