open(OUTPUT,">>",$output) or die("Could not open conf file."); open(LOG, $logfile) or die("Could not open conf file."); while (defined($line = ) ) { if ($line =~/:NOTICE:user=$contract,session=(\d+):/) { print OUTPUT $line; $echo=1; } elsif ($echo == 1) { print OUTPUT $line; if ($line =~/\)\[/) { $echo=0; } } }