title: How can I process a file two lines at a time in Perl?
body: <p>I have a signal file with each line beginning with 0 or 1.</p>
  
  <p>If I have 1 followed by 0 in the next line, then I need to process the 0 signal line.</p>
  
  <pre><code>&gt;#Sample File
  
  &gt;0
  
  &gt;0
  
  &gt;1
  
  &gt;0 (process line)
  
  &gt;0
  
  &gt;1
  
  &gt;0 (process line)
  </code></pre>
  
  my code
  
  <pre><code> OUTER : while (&lt;F&gt;) {
     if($_=~/1/){
       my $a = &lt;F&gt;
       process_line($a) if ($a=~/0/);
       next OUTER if ($a=~/1/);
     }
  </code></pre>
  
  <p>The file is huge, so I don't want to slurp.</p>