# Each word matched while (<$words_fh>) { for my $word ( split ) { if ( $teststring =~ /\Q$word/ ) { print("$teststring contains $word\n"); } } }