in reply to Re^2: Matching Multiple Alternative Patterns and Capturing Multiple Subexpressions
in thread Matching Multiple Alternative Patterns and Capturing Multiple Subexpressions

Because $$_ is a symbolic reference, I'm forced to countermand strict 'refs', but this is a rare, legitimate use of symbolic references, don't you think?

I agree. Though I most of the time just use Symbol's qualify_to_ref, an oft-forgotten very handy routine, I think using $$_ is clearer in this simple case. But I'd try to limit the scope as much as possible, and usually that involves a do { ... } construct.

return grep defined, map do { no strict 'refs'; $$_ }, 1 .. $#- ;
Here I've used (as in my original reply) that map and grep can take an expression instead of a block, so note the comma after the do block. I also check the match variables instead of the indices for definedness. It just felt nice. (In the first reply I had to check the index first.)

I'm not exactly sure why I used a BEGIN block. It seems right. Is it?

In this case it's a matter of taste. You don't need it, but there are some possible benefits in the future. Personally I stay away from them until I need them (and I rarely do). That way I know the code needs special care when I do see them in my own code. In either case, I'd keep the curly blackets to limit the scope of $bates_number_pattern.

lodin