> -----Original Message-----
> From: miette [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 09, 2002 4:53 PM
> To: [EMAIL PROTECTED]
> Subject: Getting $1 in regex in grep()
> 
> 
> I'd like to use something like this
> 
> @lines = grep(/^"(.*)",?$/, @fulltext);

You're sooo close! Just use map() instead of grep():

   @lines = map(/^"(.*)",?$/, @fulltext);
            ^^^

This works because map evaluates the regex in list context
and returns a combined list of all the return values.
The regex will return 0 elements for no match, and 1 element
for a match, so you get a list of the matches, and only
for the lines that match (just like grep).

> 
> except I want @lines to contain what would be in
> $1...that is the (.*) part instead of the whole line.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to