Re: What's in a Regex (was RFC 145)

2000-09-07 Thread Jonathan Scott Duff

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]



Re: What's in a Regex (was RFC 145)

2000-09-07 Thread Mark-Jason Dominus


2. Many people - including Larry - have voiced their desire
   to see =~ die a horrible death
 
 Please provide a look-up-able reference to Larry's saying that he
 wanted to =~ to die horrible death.  

Larry said:

# Well, the fact is, I've been thinking about possible ways to get rid
# of =~ for some time now, so I certainly don't mind brainstorming in
# this direction.

That is in 
[EMAIL PROTECTED]

which is archived at 

http://www.mail-archive.com/perl6-language-regex@perl.org/msg3.html

I think Nathan was exaggerating here, but maybe he knows something I don't.




Re: What's in a Regex (was RFC 145)

2000-09-07 Thread Nathan Wiger

Mark-Jason Dominus wrote:
 
 Larry said:
 
 # Well, the fact is, I've been thinking about possible ways to get rid
 # of =~ for some time now, so I certainly don't mind brainstorming in
 # this direction.
 
 That is in
 [EMAIL PROTECTED]
 
 which is archived at
 
 http://www.mail-archive.com/perl6-language-regex@perl.org/msg3.html
 
 I think Nathan was exaggerating here, but maybe he knows something I don't.

Yeah, that's the quote I was thinking of.

As for the "die a horrible death" thingy, people that know me will know
that I use this phrase to mean "go away" in a general yet humorous
sense. So it's not meant to put those precise words in Larry's mouth,
but just that Larry has voiced his opinions it might be nice for =~ to
go away.

I doubt anyone on the list has actually suggested anything "die a
horrible death" literally. ;-)

-Nate