in reply to Using @- & @+

@- and @+ have one element for each capturing parenthesis. If no natch is found, that element remains undefined. It also matters that you are evaluating the match in scalar contest,.

Let's add some diagnostic prints:

my $haystack = "abcdefghijklmnopqrstuvwxyz"; $haystack =~ /(abc)|(cde)|(fgh)|(ghi)|(ijk)|(pqr)|(rst)|(xyz)/g; print map {defined($_) ? " $_" : " undef"} @-; print " is \@-",$/; print map {defined($_) ? " $_" : " undef"} @+; print " is \@+",$/; __END__ 0 0 is @- 3 3 undef undef undef undef undef undef undef is @+
With all those parentheses in alternation, you are assuring that only one matches, so the rest of the data is undefined.

See perlvar for more and better on @- and @+, which refer to submatches in the last match made.

After Compline,
Zaxo