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
You cannot use \Q in a single-quoted / non-interpolated string. It must be seen by the lexer.
\Q
Anyway, tilde isn’t a meta-character.
Add use regex "debug" and you will see what is actually happening.
use regex "debug"