I\'d like to use a variable as a RegEx pattern for matching filenames:
my $file = \"test~\"; my $regex1 = \'^.+\\Q~\\E$\'; my $regex2 = \'^.+\\\\Q~\\\\E$\'; prin
As documentation says:
$re = qr/$pattern/; $string =~ /foo${re}bar/; # can be interpolated in other patterns $string =~ $re; # or used standalone $string =~ /$re/; # or this way
So, use the qr quote-like operator.
qr