sub driver{ my $pattern = shift; my $modifiers = shift; while(){ if ($_ =~ /$pattern/$modifiers){ print $_; } close LOG; } }