I think your (very interesting!) problem has been solved several times already—the main points being that
- you don't need to escape @@ in the regex (but would need to if it were followed by some alphabetic character);
- if you did, then \Q usually wouldn't do it (but seems to do it in this case, because there's no interpolation going on), but single-quote delimiters instead of ' would;
and, anyway,
- probably the problem is that your input doesn't actually contain @@ as you think it does (for example, "a@@b" is actually a@ concatenated with the stringification of @b)
—so I'll just point out one thing that no one seems to have mentioned, which is that
\Q/
\E are a pair, and
must should be used as such. Your sample code has only a
\Q, although Perl seems forgivingly to assume the
\E:
$ perl -E 'say my $rx = qr|\A(.+)\Q@@/|;'
(?-xism:\A(.+)\@\@\/)
You may also be interested in the function,
quotemeta, underlying the escape
, which works fine on @.