On Thu Sep 15 11:34:02 2016, cpan@goess.org wrote: > This is a bug report for perl from cpan@goess.org, > generated with the help of perlbug 1.40 running under perl 5.25.5. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > I'm suggesting a documentation change. perlrecharclass says "Most > characters > that are meta characters in regular expressions...lose their special > meaning > and can be used inside a character class without the need to escape > them" and > goes on to list the ones that do need to be escaped. It does *not* > list a '$'. > But this will not match a dollar sign or a comma: > > [$,] > > and it would be good advice to point out that a '$' is as special > inside a > character class as it is anywhere else in a regular expression. > > While I agree with the general thrust of the patch, I think we're going to have to brainstorm for edge cases before we nail down its final wording. Consider the following: ##### $ cat 129277-charclass-dollar.pl ##### # perl use strict; use warnings; use 5.10.1; { my $str; local $/ = "\n"; $str = 'This is a string with hard-quoted $/ in its middle.'; say $str; say ( ($str =~ m{[$/]}) ? "Yes" : "No" ); say ( ($str =~ m{[\$/]}) ? "Yes" : "No" ); say ( ($str =~ m{[^$/]}) ? "Yes" : "No" ); say ( ($str =~ m{[^\$/]}) ? "Yes" : "No" ); $str = "This is a string with interpolated $/ in its middle."; say $str; say ( ($str =~ m{[$/]}) ? "Yes" : "No" ); say ( ($str =~ m{[\$/]}) ? "Yes" : "No" ); say ( ($str =~ m{[^$/]}) ? "Yes" : "No" ); say ( ($str =~ m{[^\$/]}) ? "Yes" : "No" ); } __END__ ##### Output: ##### $ perl 129277-charclass-dollar.pl ##### This is a string with hard-quoted $/ in its middle. No Yes Yes Yes This is a string with interpolated in its middle. Yes No Yes Yes ##### Is that the output we all expect? How do we describe the behavior of the "dollar-variables" inside negated character classes? Thank you very much. -- James E Keenan (jkeenan@cpan.org) --- via perlbug: queue: perl5 status: new https://rt.perl.org/Ticket/Display.html?id=129277Thread Next