title: Search file for specific lines and store them
body: <p><strong>This is my text file...i want to search specific data and store it....</strong>
  i want to search output demand history and then print it search all *output field          and save its value=234 only and print its data i.e abc,
                                                 dfg,
                                                 jh,</p>
  
  <h3>input file:</h3>
  
  <pre><code>*output folk
   .....
   ....
   ....
  *output demand history
  *output integ
  sd,
  lk,
  pk,
  *output field, value=234;hoxbay edt
  abc,
  dfg,
  jh,
  *output field, value=235;hoxbay edt
  jh,
  lk,
  *output fix, value=555;deedfgh
  re,
  ds,
  *fgh ,val=098;ghfd
  dsp=pop
  mike oop...
  
  
  **i want this output only........**
  </code></pre>
  
  <h3>output:</h3>
  
  <pre><code>*output field, value=234;hoxbay edt
  abc,
  dfg,
  jh,
  *output field, value=235;hoxbay edt
  jh,
  lk,
  *output fix, value=555;deedfgh
  re,
  ds,
  </code></pre>
  
  <p>I have tried this.....but i don't know how to stop after </p>
  
  <pre><code>output fix, value=555;deedfgh
  re,
  ds,
  </code></pre>
  
  <h3>code:</h3>
  
  <pre><code>use strict;
  use warnings;
  use Data::Dumper;
  
  open(IN , "&lt;" , "a.txt");
  
  my $flag=0;
  
  foreach my $line(&lt;IN&gt;)
  {
    if($line=~/^\*output demand history/i)
    {
      print $line;
      $flag=1;
  
    }
  
    if($line=~/^\*OUTPUT field/i &amp;&amp; $flag==1)
    {
      print $line;
      my @array1=split("," ,$line);
      my $temp1=shift @array1;
      my @array2=split(";",$temp1);
      my $elset=shift @array2;
  
    } 
  
    if($line=~/^\*OUTPUT FIX/i &amp;&amp; $flag==1)
    {
      print $line;
  
      my @array3=split("," ,$line);
      my $temp2=shift @array3;
      my @array4=split(";",$temp2);
      my $nset=shift @array4;
    }
  }
  </code></pre>