in reply to Order of evaluation/interpolation of references

Perhaps because "${X()}${X()}" does ${X()} . ${X()} before any stringification makes a copy, so both aliases to the hidden $x are incremented again before their values are copied to the new string. While the other case turns into ( ${X()} . ' ' ) . ${X()} so the first alias to the hidden $x gets copied into a string with a trailing space before $x gets incremented again.

Lots of surprises to discover when you do such things.

- tye        

Replies are listed 'Best First'.
Re^2: Order of evaluation/interpolation of references (alias vs copy)
by LanX (Saint) on Mar 07, 2012 at 21:49 UTC
    I think you're right!
    lanx:/tmp$ perl -MO=Deparse,-p,-q -e 'print "${X()} ${X()}\n"' print((((${X();} . ' ') . ${X();}) . "\n")); lanx:/tmp$ perl -MO=Deparse,-p,-q -e 'print "${X()}${X()}\n"' print(((${X();} . ${X();}) . "\n"));

    Cheers Rolf