title: How do I extract lines between two strings
body: <p>I am an absolute beginner in perl and I am trying to extract lines of text between 2 strings on different lines but without success. It looks like I`m missing something in my code. The code should print out the file name and the found strings. Do you have any idea where could be the problem ? Many thanks indeed for your help or advice. Here is the example:  </p>
  
  <pre><code>*****************
  example:
  START
  new line 1
  new line 2
  new line 3
  END
  *****************
  </code></pre>
  
  <p>and my script:</p>
  
  <pre><code>use strict;
  use warnings;
  
  my $command0 = "";
  opendir (DIR, "C:/Users/input/") or die "$!";
  my @files = readdir DIR;
  close DIR;
  splice (@files,0,2);
  
  open(MYOUTFILE, "&gt;&gt;output/output.txt");
  foreach my $file (@files) {
      open (CHECKBOOK, "input/$file")|| die "$!";
      while ($record = &lt;CHECKBOOK&gt;) {
          if (/\bstart\..\/bend\b/) {
              print MYOUTFILE "$file;$_\n";
          }
      }
      close(CHECKBOOK);
      $command0 = "";
  }
  close(MYOUTFILE);
  </code></pre>