If word1 and word2 are on the same line, you could do something like this:

open(INFILE,"myfile.txt");
open(OUTFILE,">results.txt");
while(<INFILE>){
   while($_ =~ /word1(.*)word2/g){ #get all characters between word1 and
word2, one match at a time
      print OUTFILE $1."\n";
   }
}

Someone else might have a better one, though.

-----Original Message-----
From: Raghupathy, Ramesh . [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 12, 2002 11:29 AM
To: [EMAIL PROTECTED]
Subject: pattern match


Hi All,

   I have a file which has several occurances of word1 and word2
interspersed with other text. I need to extract only the text which is
contained between consecutive occurances of  word1 and word2 in that order.
Is it possible to write a pattern match for this ?

Thanks,
Ramesh

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------------------
This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to