in reply to Re^5: perl indication of end of string already matched
in thread perl indication of end of string already matched
Good point, although in this case those variables also don't allow one to differentiate between the last two matches:
$ perl -MData::Dump -e '$a="abc";for(1..6){ $a=~m/.|$/g; dd \@-,\@+ }' ([0], [1]) ([1], [2]) ([2], [3]) ([3], [3]) ([3], [3]) ([0], [1])
Update: Hmm, well they can if one adds capture groups, which is kind of the same workaround as I showed here.
$ perl -MData::Dump -e '$a="abc";for(1..6){$a=~m/(.|$)/g; dd \@-,\@+}' ([0, 0], [1, 1]) ([1, 1], [2, 2]) ([2, 2], [3, 3]) ([3, 3], [3, 3]) ([3], [3, 3]) ([0, 0], [1, 1])
|
|---|