in reply to Re^2: returning matched word from string
in thread returning matched word from string

So you want to match the string if any of the words on the line match? Did you want to know if "each word matched" or if "any word matched"?
# Any word matched while (<$words_fh>) { my $re = join '|', map quotemeta, split; if ( $teststring =~ /($re)/ ) { print("$teststring contains $1\n"); } }
# Each word matched while (<$words_fh>) { for my $word ( split ) { if ( $teststring =~ /\Q$word/ ) { print("$teststring contains $word\n"); } } }

Replies are listed 'Best First'.
Re^4: returning matched word from string
by monaghan (Novice) on Jul 23, 2008 at 18:38 UTC
    That first method did the trick! Thank you very very much for your help everyone. This was my first time on PerlMonks and it was fast and easy. I think now I need to convert this array of acronyms to a hash.