in reply to Re: Why does my Perl regex substitution for linebreak fail?
in thread Why does my Perl regex substitution for linebreak fail?

igelkott -

Your answer got right to the core of the issue. I searched for \r and got matches in exactly those lines which resisted the replacement. What exactly is this \r character, anyway? I have no idea how that \r entered my fully Linux-based and Linux-generated file.

Any thoughts on this?

Thanks again for shedding some light on this.

Cheers -

Pat
  • Comment on Re^2: Why does my Perl regex substitution for linebreak fail?

Replies are listed 'Best First'.
Re^3: Why does my Perl regex substitution for linebreak fail?
by igelkott (Priest) on Mar 06, 2008 at 18:37 UTC
    Line-endings: \r and \n (CR and LF)
    •  \n -> unix
    •  \r -> mac
    • \r\n -> pc

    Exactly how pc line-ending got in your file, I couldn't say but I would guess that the data has passed through a windows machine at sometime. Some file transfer methods take care of line-endings and others don't.

      Good stuff, igelkott.

      Thanks a million for your help! I'll spend some more time wondering just how the \r got in there.

      Just out of curiosity - could it have crept in due to any of my Linux or text editor settings - or maybe even character encodings? I checked for the obvious (to me) editor settings in KWrite but could not spot any pointers to Windows formats there.
      Also, the file did not get routed through the network at any point in time ... oh, wait a minute: I did send a copy of it via uuencode. Would that have done anything to the original file? Probably not ...

      Cheers -

      Pat
        In the Kwrite menu, check Tools -> End of Line.

        I've never heard of uuencode doing something like this.