in reply to regular expression with @@/
I think your (very interesting!) problem has been solved several times already—the main points being that
must should be used as such. Your sample code has only a \Q, although Perl seems forgivingly to assume the \E:
, which works fine on @.
- 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)
You may also be interested in the function, quotemeta, underlying the escape$ perl -E 'say my $rx = qr|\A(.+)\Q@@/|;' (?-xism:\A(.+)\@\@\/)
In Section
Seekers of Perl Wisdom