----- 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



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to