use strict; use Regex::PreSuf; my @array = qw( foo bar baz ); my $re = presuf(@array); my $bigstring = 'whatever'; if ($bigstring =~ /$re/o) { print "it matched"; }