http://qs321.pair.com?node_id=11118053


in reply to ${^POSTMATCH} problem

Internally, the expression is essentially saving a reference to ${^POSTMATCH}, which it will fetch from later when it does the concatenation. Depending on the order that the concatenation is performed in, this can lead to varied results. Small changes in implementation can impact this, but most likely this changed due to the introduction of the multiconcat op.

You can force early fetching of the ${^POSTMATCH} variable by putting it in double quotes. This can be a good practice in other places when using regular expression globals, such as when passing match variables ("$1", "$2") to functions.

Replies are listed 'Best First'.
Re^2: ${^POSTMATCH} problem
by LanX (Sage) on Jun 14, 2020 at 14:31 UTC
    This effect is well known with function arguments and any repeated variables , but IMHO not common with built-in operators.°

    I consider this an implementation glitch which should be fixed if possible.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    °) some take lvalues like substr but there is no reason to consider concat alike

    Update

    Changed splice to substr

Re^2: ${^POSTMATCH} problem
by pl_pm (Initiate) on Jun 21, 2020 at 19:22 UTC

    I see, thank you for the explanation.

    So, in this case, the point is that if I “wrap” scalar into an expression (stringification, concat wish an empty string,...), the multiconcat will use the result of the expression instead of a reference. It works well, thank you. However, I have used an array and join(map()) to fix the script.

    Thank you all.