in reply to Re^2: Regex result being defined when it shouldn't be(?)
in thread Regex result being defined when it shouldn't be(?)

((this)?|(that)?|(third_thing)?)
...
... I don't even trust it. ... there's probably 4 capture groups created as a result.

Just as an aside, the  (?|(pat)|(te)|(rn)) "branch reset" pattern introduced with Perl version 5.10 will suppress the creation of a slew of captures in a case like this:

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $s = 'apathetic'; ;; my @captures = $s =~ m{ (pat) | (te) | (rn) }xms; dd \@captures; ;; @captures = $s =~ m{ (?| (pat) | (te) | (rn)) }xms; dd \@captures; " ["pat", undef, undef] ["pat"]
See Extended Patterns in perlre.


Give a man a fish:  <%-{-{-{-<