Say I have the string “i zipped the fezz and it blipped like a baa” and I have an array of words (moo, baa, zip, fjezz, blaa) that I wanted to test to see it they’re contained in the string, is there a way of doing so without either using | in the regex or iterating over each word?
TIA
If you’re using Perl 5.10, you can use the smart match operator:
The above will do an equality check (equivalent to
grep $_ eq $str, @words). If you want a regex match, you can useOtherwise, you’re stuck with
greporfirstfrom List::Util: