in reply to An obscure side effect?

Good one. This exhibits the nearly same behavior under 5.8 on Linux. (I get a single character printed the second time around, though the string is still two bytes long.)

I poked at it a bit to put the parameters into temporaries, but got the same effect. I also tried using a different lexical variable for the second call, but still got the same effect. When I pull the characters out and do the XOR swap on them, I get the right result. That seems to point the finger at substr(). I wonder if some internal optimization has gone awry.

Time for a bug report.

Replies are listed 'Best First'.
Re: An obscure side effect?
by Abigail-II (Bishop) on Aug 03, 2003 at 12:45 UTC
    On Linux you get a two byte string, where the first character is "\x00", which isn't printable. I expect that on Windows you get the same, but that that character is printed as a space.

    Abigail

Re: Re: An obscure side effect?
by BrowserUk (Patriarch) on Aug 03, 2003 at 05:11 UTC

    Reported: Ticket #23207.

    Thanks for the confirmation.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.