in reply to Searching for a string in a text and printing the next few lines

What Corion said, that's not a question it's a spec. Have a go at coding up the above in Perl.
When it doesn't work and the error messages don't point you in the right direction
      use diagnostics;
If that fails ask a question with some evidence of effort on your part.