title: Unable to print after while loop in perl
body: <pre><code>BEGIN {
     use FindBin;
     $scriptsDir = $FindBin::RealBin;
  }
  
   sub print_log {
    ($log, $msg) = ($_[0], $_[1]);
    print $log $msg;
       }
  
  
  $opt_rh_gsr = &quot;path_to_file&quot;;
  open(FO, &quot;$opt_rh_gsr&quot;) || die &quot;-F-: Can not open file \n&quot;;
  while(&lt;FO&gt;) {
    if(/vdd_nets/) {
            $vdd_net = 1;
            $vdd_string = &quot;VDD_NETS \{ \n&quot;;
                 }
    if(/gnd_nets/) {
            $gnd_net = 1;
   }
       if(($gnd_net == 1)) {
       chomp();
       $new_line = $_;
       @split_new_line = split(&quot;:&quot;, $new_line);
       }
     if(($gnd_net == 1) &amp;&amp; /\}/) {
        $gnd_net = 0;
        $gnd_string .= &quot;\} \n&quot;;
        exit;
         }
    if($vdd_net) {
      if(/^\s*\S+\s+\S+\s+{/) {
        $paren++;
      }
      if (0 != $paren &amp;&amp; /^\s*(\w+)\s*$/) {
       $vdd_nets{$1} = $parenvolt;
        next;
      }
      if(/^\s*}\s*$/ || /^\s+$/) {
        if (0 == $paren) {
          $vdd_net = 0; next;
        }
        else {
          $paren--;  next;
        }
      }
      chomp();
      if(/\s*\}\s*$/ &amp;&amp; ($vdd_net == 1)){
      s/\'//g;
      $vdd_net = 0;
      @_ = split(&quot;:&quot;);
      $vdd_string .= &quot;$_[0]  $_[1] \n&quot;;
      $vdd_string .=  &quot;\} \n&quot;;
      next;
      }
        
    if($gnd_net) {
      if(/^\s*\}\s+$/ || /^\s+$/) {
        $gnd_net = 0;
        next;
      }
      #chomp();
      if(/\s*\}\s*$/ &amp;&amp; ($gnd_net == 1)){
      s/\'//g;
      $gnd_net = 0;
      }
      @_ = split();
      $GNDNET = $_[0];
      if ($_[0] =~ /^\w+$/) {
        $groundnets{$_[0]} = 1;
       
      }
    }
  }
  }
  print &quot; done reading \n&quot;;
  close(FO); 
  
  print &quot;closed file \n&quot;;
  </code></pre>
  <p>The above is not printing the last 2 print statement (before and after the close of file handle). I tried print STDOUT, that didn't work. I also tried to flush, that didn't work either.</p>
  <p>The script is exiting after executing, so it  is not stuck in a infinite loop anywhere. I tries using perl5.6 and 5.8, but both of them have the same problem.</p>