while ($line ne ')') { $line_cnt++; if ($line =~ /$var_of_interest/) {$keep = 1}; } if ($line_cnt > $n and $keep == 1} then {$table_hash{$table_nm} = 1;}