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

Getting $1 in regex in grep()

Thread Next
January 9, 2002 13:53
Getting $1 in regex in grep()
Message ID:
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!

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About