$var = '...'; $re = qr/abc\Q$var\Eghi/; foreach (qw( abcdefghi abc...ghi )) { print("$_ ", /$re/ ? "matches" : "doesn't match", "\n"); }