in reply to regex eval capture weirdness
Yes, this appears to be a scoping problem. I'm not fully versed in what is going on, but based on similar issues I've seen in the past, by safest suggestion is to turn %mv into a global (our) var, localize it on entry to domatch, and then return a reference to a copy of it like return { %mv }.
I think what's happening is that because the regular expression doesn't change, it only gets compiled once and thus the %mv within those ?{} blocks gets bound to the lexical %mv that's created the first time domatch gets called. To see if I'm right, try saving the reference to the return value from domatch only the first time it's called but printing the contents of it after each iteration.
If I'm right, this is somehow related to the "won't stay shared" warning though I admit I don't have a solid grasp on why.
|
|---|