use warnings; use strict; use feature 'say'; my @strings = ( "Bob said hello\n", "Alice doesn't like Chris\n", "This line won't match\n" ); for (@strings){ say "yay!" if /(?:\bAlice\b|\bBob\b|\bChris\b)/; }