in reply to Re: substring function
in thread substring function

I do want to preserve that ^M character and also the new line character. Please give any suggestion how to use substring func.to do just that.

Replies are listed 'Best First'.
RE: RE: Re: substring function
by Fastolfe (Vicar) on Sep 30, 2000 at 01:16 UTC
    If you literally want to clear the 2nd character from the end (i.e. byte 49 of 50 bytes), you could do this with substr:
    substr($string, -2, 1) = undef;
    That should neatly cut that character out of the string. My instincts tell me you're doing something "the hard way", though. I really cannot see the value of having a binary ^M sitting out near the end of ASCII text file lines. I would only expect to see that with improperly transferred files between systems that use incompatible newlines. I don't quite understand what you're trying to accomplish, but my gut tells me you're going about this problem (whatever your true problem is) the wrong way.

    Good luck.