... my $paramre = join '|', @params; ... while () { next unless /\s($paramre)\s*(\d*)/; print OUTPUT "$1 $2\n"; } ...