my $found_date = 0; while( ) { $found_date = 1 if /$date/o; print LOGFILE if $found_date; }