Sven Bentlage wrote: > > Hi guys, Hello,
> I'm not sure why the first regex (see below) does not grep the correct > line. The 2nd one does. (but it greps the whole line and not only the > part I want to have since the delimiter is \n) > Would be nice if you could give me a hint what I'm doing wrong with the > first regex: > I want to grep only the part from "Date:" til "2002". > > Line: > > Date: Sat, 8 Jun 2002 13:09:50 +0000 (GMT) > > regex 1: > ($date) = grep > (m/(?=Date:(\n+\w+),)\s{1,2}\d{1,2}\s{1,2}\w{3}\s{1,2}\d{4}\s/,@mail); > > regex 2: > ($date) -= grep (m/(?=Date:)(.*)\n/,@mail); If you have only one line then why are you storing it in an array? If you want to get the dates from all the lines in the array then why are you storing them in a scalar? grep() returns the scalar it is evaluating if the expression is true and nothing if the expression is false. $line = 'Date: Sat, 8 Jun 2002 13:09:50 +0000 (GMT)'; ($date) = $line =~ /Date:\s*(.+?)\s+\d{4}/; # OR for ( @mail ) { if ( /Date:\s*(.+?)\s+\d{4}/ ) { $date = $1; last; } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]