I'm not sure what you want. It's one of the following two.
1) Maybe you're looking for qr/.../.
outputs$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:\.)
2) Maybe you're looking for \Q..\E (or quotemeta).
outputs$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
In reply to Re: variable interpolation sans character interpolation
by ikegami
in thread variable interpolation sans character interpolation
by vacant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |