On Sun, 24 Jun 2001, Bradford Ritchie wrote:

> Wow, thanks for all the replies.  I'm surprised no one commented on my question 
>about the matching operator itself:
>
> > Does anyone know why m//g only returns true on success instead of
> > returning the number of matches like s///g and tr/// do.
>
> I realize I'm not identifying some major flaw in the language and but
> I can't think of any reason why m//g was made not to return the number
> of matches while s///g was.  It just seems like it should.

s//g and tr/// are different than m//g because they actually change the
input data whereas m//g doesn't.  m//g *does* return the number of matches
if you use it in the correct context (as we have already discussed to
death...).  I think it's more a matter of usage -- the match operator
tends to be used in a boolean expression than do s// and tr///.

-- Brett
                                   http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
Keep the number of passes in a compiler to a minimum.
                -- D. Gries

Reply via email to