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