Perl script to search a line and copy it to another line

Hi
I have a log file (say log.txt). I have to search for a line which has the string ( say ERROR) in the log file and copy 15 lines after this into another file (say error.txt). Can someone give me the code and this has to be in PERL

Thanks in advance
Ammu

Why does it have to be in Perl? Is it homework?

It's a simple problem to solve in awk:

awk '/ERROR/ && target == 0 { target = NR + 15; next }
target && NR <= target { print }
' log.txt > error.txt

I am getting below error. I wanted it in perl because my script is in PERL.
Can some one give me the code

awk: syntax error near line 1
awk: bailing out near line 1

Thanks
Ammu

Generic example, apply your own file I/O operations as required.

while (<>) {
   if (/ERROR/) {
      <> for (1..15);#<- skips 15 lines
      print "here is the line you wanted: $_";
   }
}