Matching only the final match is not desirable, in my opinion. It should match 
the string traversed by all the matches in $0, including intervening 
separators, if any. The problem is that ~$0 has spaces interpolated, which will 
match only if the separators happen to be a single space, so there is now a 
$0.backref that returns the string actually traversed by the entire list of 
matches. Matching $0 as a backref should use that method.

    > p6 'my $abc = "  a,b,c,  "; $abc ~~ /(\w+ % ",")/; say $0.backref'
    a,b,c

BTW, matching just the final match can be accomplished with something like 
$($0[*-1]), I suspect.

Reply via email to