... $-[0] requires /...(...).../ re positional variables.
You show a capturing group in your example and refer to "positional variables", so I thought I'd mention that $-[0] is the offset of the start of the overall match and does not depend at all on capture groups.
c:\@Work\Perl>perl -wMstrict -le "my $s = 'xxxabcyyy'; ;; print qq{overall match begining at offset $-[0] in '$s'} if $s =~ m{ abc }xms; " overall match begining at offset 3 in 'xxxabcyyy'
(And BTW: I've been practicing goofs for quite a while myself.)
In reply to Re^3: position of first matching regex
by AnomalousMonk
in thread position of first matching regex
by techtaskers.com
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |