in reply to String handling frustrations

Whatever wrote the file in question tacked the carriage return onto the line in question. It didn't have to be a carriage return; it could have been a newline character instead, or both. (I think Windows uses just the carriage return, and UNIX uses both?) At any rate, the end-of-line termination may not always be a carriage return (\r), so removing only that may not be enough. Using the regular expression may not be enough, either, since it deals only with lines (unless you're using a '/m', as in tr/\r//m, I believe.

I guess I'd probably also chomp $bob, which should get rid of the line terminator too. I believe chomp only removes the character defined by $/, so the tr/\s// is still needed too.

Replies are listed 'Best First'.
Re: String handling frustrations
by cLive ;-) (Prior) on Jul 31, 2001 at 01:36 UTC
    (I think Windows uses just the carriage return, and UNIX uses both?)

    Close, the other way round though;

    • \r\n - Window$
    • \n - *nix
    cLive ;-)

      And, for completeness:

      • \r - MacOS

      This is not a portability issue for scripts (MacPerl Does What You Mean when you print "\n"), but it is for the files containing them. :-)



      If God had meant us to fly, he would *never* have given us the railroads.
          --Michael Flanders

Re: Re: String handling frustrations
by troll314 (Initiate) on Jul 31, 2001 at 01:25 UTC
    interesting..

    though jaffy's method works in my case and since pgp is not changing its fine.

    the other thing I could have done I think, would have been to just not include the \r in the first place.

    this is my line

    /SALE .*/

    I would need to modify it so that it goes to the end of the line but doesn't include \r.



    Except I dunno how to do that. :P
    ----------------------
    My very owen signature
      I'm all in favor of sticking with what works, but you may want to check out Ovid's Death to Dot Star. I think it will give you alternatives to your regex, including how to modify to the end of the line.