You can't escape with backslashes inside a character class.
Put the minus at the end and drop all backslashes, unless you want to match \ .
A counterexample:
(But I agree that putting the - at the end and dropping the backslashes would have the same effect.)c:\@Work\Perl\monks>perl -wMstrict -le "my $s = 'abc\ZD+A-G\HJxyz'; print qq{'$s'}; ;; $s =~ m{ ([A\-Z\+GD]+) }xms; print qq{'$1'}; " 'abc\ZD+A-G\HJxyz' 'ZD+A-G'
Give a man a fish: <%-{-{-{-<
In reply to Re^2: Pattern matching fails because of special characters
by AnomalousMonk
in thread Pattern matching fails because of special characters
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |