On 11/24/07, Avinash S <[EMAIL PROTECTED]> wrote: > I want to extract only the block which has the key word [WARNING]
It sounds as if you wish to process many lines at once, rather than one line at a time. Is that right? > while (<FILE>) > chomp;chomp; Why two chomps? The first one removed the newline. The second one will accomplish nothing. (But it's good Perl poetry. :-) > my ($line) = $_; > if ($line =~ /-->.*<--/) { > $field_type = $line; > $field_type =~ s/-->(.*)--</$1/; > } Your second pattern has a different arrow on the right than the first. Is that your problem? That if-block could be simplified, I think: if ($line =~ /-->(.*)<--/) { $field_type = $1; } If your data comes in multiple-line chunks, it may be easiest to gather it up a chunk at a time for processing, instead of viewing it a line at a time. Whenever you read the end of a chunk, you would send the whole chunk off for processing, perhaps in a subroutine. Perl's patterns can work with multiple-line chunks without much trouble. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/