Re: RFC 110 (v3) counting matches

[email protected] (Jonathan Scott Duff)
Newsgroups perl.perl6.language.regex
Message-ID <[email protected]>
On Tue, Aug 29, 2000 at 09:23:59AM -0600, Tom Christiansen wrote:
>     () = $string =~ m{
> 	(\d\d) - (\d\d) - (\d\d)
> 	(?{ push @dates, makedate($1,$2,$3) })
>     }gx;

That empty list to force the proper context irks me.  How about a
modifier to the RE that forces it (this would solve the "counting matches"
problem too).

	$string =~ m{
	    (\d\d) - (\d\d) - (\d\d)
	    (?{ push @dates, makedate($1,$2,$3) })
	}gxl;

	$count = $string =~ m/foo/gl;		# always list context

-Scott
-- 
Jonathan Scott Duff
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.