foreach my $query(@query){ next if $query eq ''; print "I found: $query" if $line =~ /\Q$query/; }