develooper Front page | perl.beginners | Postings from January 2002

Getting $1 in regex in grep()

Thread Next
From:
miette
Date:
January 9, 2002 13:53
Subject:
Getting $1 in regex in grep()
Message ID:
20020109215320.33977.qmail@web20905.mail.yahoo.com
I'd like to use something like this

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

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

I was doing this

for (@fulltext) {
   if (/^"(.*)",?$/) {
       push (@lines,$1);
   }
}

but it seems like the grep might be more efficient.

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About