On Wed, Aug 16, 2000 at 10:20:28AM -0500, Jonathan Scott Duff wrote:
> On Wed, Aug 16, 2000 at 03:04:19PM -0000, Perl6 RFC Librarian wrote:
> > =head1 ABSTRACT
> >
> > Provide a simple way of giving a count of matches of a pattern.
>
> We already have this:
>
> $count = () = m/foo/g;
Which is admittedly cute but let's face it, also rather dirty trick.
> > =head1 DESCRIPTION
> >
> > m//gt would be defined to do the match, and return the count of matches, this
> > leaves all existing uses consistent and unaffected. /t is suggested for
> > "counT", as /c is already taken. Using /t without /g would be result in
> > only 0 or 1 being returned, which is nearly the existing syntax.
>
> Better would be to redefine what m//g means in a scalar context.
>
> $_ = "foofoofoofoofoofoofoo";
> $count = m/foo/g;
>
> 1 is just as true as 7.
I like this. No extra //modifiers to learn.
--
$jhi++; # http://www.iki.fi/jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen