I like your idea, but... It is not how (anonymous) captures in Perl work, do they? I mean, nothing is guaranteed about the value of $1, $2 etc. in a regexp with captures, if the regexp doesn't match.
Of late, I'm not sure that's so true. The most recent perls (the last year anyway) ensures that all potentially used capture variables are cleared regardless of whether the expression succeeds. So /((...)|(...))/ addresses $1, $2, and $3. Since the fix, you can guarantee that each variable will have a sane value. You still can't guarantee $4 -> on though. I think. Or could those be guaranteed already?