On Wed, Sep 06, 2000 at 03:37:55PM -0400, David Corbin wrote:
> Question: Is there value in extending the regex/pattern engine to
> support matching patterns in a list of foobars?
>
> I can see this taking two forms (beyond the strings we have today).
>
> One is matching number patterns (fibonaci, etc), and the other is
> matching lists of objects. The goal here would be to leverage all the
> GENERIC knowledge/power such as +, *, ? {x,y} [] | (?=) etc., and use
> this power where the fundamental thingy being matched is not a
> character.
We can already match patterns in numbers as they are autoconverted
into strings as needed. To match a pattern against an object, I
expect the same treatment from Perl. (i.e., the object's "to string"
method is called before the match)
But you said "lists" up there and that sparked an idea in me ... What
does
@a =~ /pattern/;
currently do? AFAICT, nothing useful. But it could be a syntactic
shorcut for a pattern matching grep()
i.e.,
@a = @b =~ /pattern/; # equivalent to ...
($a) = grep { /pattern/; } @b; # but stops on first match
and
@a = @b =~ /pattern/g; # equivalent to ...
@a = grep { /pattern/; } @b;
Also, it'd be nice if
@a =~ s/foo/bar/g;
did something similar.
Comments?
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]