Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: ${^POSTMATCH} problem

by Haarg (Curate)
on Jun 14, 2020 at 14:09 UTC ( #11118053=note: print w/replies, xml ) Need Help??

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


    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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11118053]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2023-06-05 23:59 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (26 votes). Check out past polls.