#!/usr/bin/perl use strict; use warnings; my @arr=('cool','guy','here'); my $joined_rx = join( '|', map { quotemeta($_) } @arr ); my $str1="I am cool"; if ($str1 =~ m/$joined_rx/) { print "Matched"; }