----- Original Message ----- From: "Chris Charley" <[EMAIL PROTECTED]> Newsgroups: perl.beginners To: <[EMAIL PROTECTED]> Sent: Thursday, June 03, 2004 7:09 PM Subject: Re: printing contents between lines
> > ----- Original Message ----- > From: "Sidharth" <[EMAIL PROTECTED]> > Newsgroups: perl.beginners > To: <[EMAIL PROTECTED]> > Sent: Thursday, June 03, 2004 3:44 PM > Subject: printing contents between lines > > > hi all , > consider the contentes of file as below > > [snip file contents] > > how to print all the line between tools: and # Not a target: only > > Hello Sidharth, > > The following code will do it :-) > > while(<>) { > if (my $line = /tools:/ .. /# Not a target:/) { > print unless $line =~ /E/; > } > } > > Note: $line will contain number of lines inclusive from 'tools:' until '# > Not a target:'. The last line, in addition to the count will have an 'E0'. > That is, if there are 6 lines, $line would have '6E0' on the last line. > > Chris I see that you didn't want 'tools:' printed by your specifications. Change line above to: print unless $line == 1 || $line =~ /E/; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>