in reply to Re: Get file part from the section where the matched pattern is found.
in thread Get file part from the section where the matched pattern is found.

Hi Ansh, Thanks for that code. How could I modify the code if I want to print
startdexdbnjcrk this when be shown
from the sample text you have chosen. Thanks in advance.
  • Comment on Re^2: Get file part from the section where the matched pattern is found.
  • Download Code

Replies are listed 'Best First'.
Re^3: Get file part from the section where the matched pattern is found.
by ansh batra (Friar) on Nov 29, 2011 at 11:03 UTC

    if you meant that you want to print the line with the regex and the next line to it
    then simply add last; in the first if section

    if($found) { print "$line"; last; }
    this will get you the output
    startdexdbnjcrk this when be shown

    UPDATE:and if you want to print more lines then youll be needing a counter and check each time with "if" weather the desired number of lines have been printed or not. if yes then exit.


    there be many shortcuts but i guess this one is the simplest for a newbie like me to understand