in reply to Tracking down an Lvalue bug?

Hmm, are you sure you want 256x1024**2 in that substr? I think this is increasing the number beyond what you intended , which doesn't matter with substr because you're replacing all that trailing string with one char, but does matter with vec because nothing is cut-off

Adjusted for my machine I run

A perl -e"$x=chr(0);$x x=5*1024**2; <>;$r=\substr($x, 2*1024**2); <>;vec($$r,2*1024**2-1,1)=1; <>"

B perl -e"$x=chr(0);$x x=5*1024**2; <>;$r=\substr($x, 2*1024**2); <>;substr($$r,2*1024**2-1,1)='x'; <>"

And I consistently get results like
AB
7,760 k
7,776 k
10,876 k
7,760 k
7,776 k
10,880 k

Replies are listed 'Best First'.
Re^2: Tracking down an Lvalue bug?
by BrowserUk (Patriarch) on Mar 17, 2012 at 22:07 UTC

    Grr. That'll teach me to try reduce my testcase to a one-liner :(

    This 256x1024**2 was intended to be 256*1024**2. Surprisingly (or not) neither strict nor warnings catch the typo.

    And when corrected the dynamics of the bug change substantially.

    Thanks for calling me on it. Back to the drawing board!


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Back to the drawing board!

      What are you trying to do?

        Demonstrate that taking an lvalue substr ref causes the referenced substring to be copied, And that this is a bug.