Suppose I use an s/// to alter a string but also to capture some substrings en passant. Suppose I have lots of pairs of capturing parentheses, so in order to put each substring into its own scalar I have to do something like my ($alpha, $beta, $gamma, $delta, $epsilon, $zeta) = ($1, $2, $3, $4, $5, $6);. But that seems redundant, as well as a little dangerous, since every time I add or remove a pair of capturing parentheses I have to remember not only to add or remove an lvalue but also to resize the list of rvalues.
What I'd really like to be able to do is something like my ($alpha, $beta, $gamma, $delta, $epsilon, $zeta) = @SOMEVAR;, where @SOMEVAR is one of those obscure punctuation variables. Except no such variable seems to exist. I can imagine various hacks to simulate one, like using symbolic references to collect $1 through ${@+}, and I can imagine workarounds, like using named captures. But I think there really ought to be a simple, fast, unlikely-to-break way to get all the (anonymous) captures from the last successful match as a list. Anybody know of one?
(Note that since I'm using s/// instead of m//, the return value of the pattern-matching operation isn't helpful.)
In reply to Get all captured substrings after a substitution by Polynomial
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |