Thanks for the answer , the problem is how to get the first word into some kind of variable . Suppose i call the programn with >_perl my_prog.pl session1.in > OUT.out I have to get the FIRST word of the session1.in then check if there is another one in the text, then print the text between that word and its repetition.
--- Manav Mathur <[EMAIL PROTECTED]> wrote: > > |-----Original Message----- > |From: lio lop [mailto:[EMAIL PROTECTED] > |Sent: Tuesday, April 19, 2005 5:44 PM > |To: beginners@perl.org > |Subject: Match a pattern > | > | > |I need to print the text between two words > | that are in different > |lines. > | > > Assuming you want to get all lines between lines > containing 'startword' and > the next line which contains 'endword' > > my $word1 = qr{startword}i ; > my $word2 = qr{endword}i ; > while (<DATA>) { > print if (/\b${word1}\b/../\b${word2}\b/) > } > > If the words are the same, replace the print if line > with > > print if (/\b${word1}\b/.../\b${word1}\b/) ##3 dots > is important > > the regex depends on you. If you want, you can > remove the i to compile a > case-sensitive regex. > > > | > > > > _________________________________________________________ Do You Yahoo!? Información de Estados Unidos y América Latina, en Yahoo! Noticias. Visítanos en http://noticias.espanol.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>