Turns out I actually used m//g, not s///; goodness knows why I thought otherwise. And it does look like the best solution for my situation is indeed to use named captures, since I'm running perl 5.10.0. I just have to make sure to copy %+ into a lexical hash so all the captures remain accessible after I've used another regex. In future cases where I really do want seperate lexicals as opposed to a hash (and hence anonymous as opposed to named captures), I guess I can use @+ and @- with substr or eval, as has been suggested; I'd just want to benchmark each method to see which is fastest. Thank you, kind monks.
| [reply] |