Two weeks ago, Nicholas Clark wrote:

> So would it be possible for s/// to have the same return values as m//
> in perl6?

Since no one authoritative has responded to this, I will just add my
support that it seems like a reasonable request.

s/// currently "returns the number of substitutions made. Otherwise it
returns false".

If s/// were to return the $0 object from its matching pass, $0 would
evaluate to true or false in boolean context, depending on if a match was
successful, and would evaluate the number of matches in numeric context.
Which is the same behavior as the perl5 s/// return value.  (Actually s///
returns "" on no matches now, whereas $0 would evaluate to false or 0
depending on context, but I doubt that would be a serious compatibility
issue.)

And getting the matching values before substition was done is a bonus in
list context.

~ John Williams


Reply via email to