$ perl -MO=Deparse,-p crates ($what = '[box]'); foreach $_ (('in[box]', 'out[box]', 'white[sox]')) { if (/\Q$what\E/) { print("$_ matched!\n"); } } crates syntax OK