On Thu, May 12, 2005 at 08:10:42PM -0700, Larry Wall wrote:
> On Thu, May 12, 2005 at 02:55:36PM -0500, Patrick R. Michaud wrote:
> : My suggestion is that a match object in numeric context is the
> : same as evaluating its string value in a numeric context. If
> : we need a way to find out the number of match repetitions (what
> : the numeric context was intended to provide), it might be better
> : done with an explicit C<.matchcount> method or something like that.
>
> I think we already said something like that once some number of
> months ago. +$1 simply has to be the numeric value of the match.
> It's not as much of a problem as a Perl 5 programmer might think,
> since ?$1 is still true even if +$1 is 0. Anyway, while we could have
> a method for the .matchcount, +$1[] should work fine too. And maybe
> even [EMAIL PROTECTED], presuming that "a match object can function as an
> array"
> actually means "a match object knows when it's being asked to supply
> an array reference".
So the "counting" idiom in S05 becomes one of:
$match_count += @{m:g/pattern/};
$match_count += list m:g/pattern/;
$match_count += m:g/pattern/.matchount;
$match_count += (m:g/pattern/)[]; # maybe
???
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]