Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 44620
Status: rejected
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: andyb [...] operamail.com
Cc: setitesuk [...] gmail.com
AdminCc:

Bug Information
Severity: Important
Broken in: 1.098
Fixed in: (no value)



CC: setitesuk [...] gmail.com
Subject: Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters
Hi, Apologies if this has already been flagged, but I couldn't locate something like it. ProhibitEscapedMetacharacters disallows escaping . as in my ($dtfn) = $fn =~ m{([[:lower:]\d_\-\./]+)}mixs; However, trying to turn it into a character class as follows my ($dtfn) = $fn =~ m{([[:lower:]\d_\-[.]/]+)}mixs; Breaks the code, and the only POSIX option I can find close to this is [:punct:] however, it is important that I only match a literal ., in case of problems if it matches other punctuation. This is forcing us to use a ## no critic (RegularExpressions::ProhibitEscapedMetacharacters) on the line, in order to ensure that we pass PerlCritic I hope that you will have time to look at this. Cheers Andy
On Fri Mar 27 07:44:50 2009, SETITESUK wrote: Show quoted text
> Hi, > > Apologies if this has already been flagged, but I couldn't locate > something like it. > > ProhibitEscapedMetacharacters disallows escaping . as in > > my ($dtfn) = $fn =~ m{([[:lower:]\d_\-\./]+)}mixs; >
Have you tried my ($dtfn) = $fn =~ m{([[:lower:]\d_\-./]+)}mixs; without the '\' in front of the '.'? You are already inside a character class at this point, and that means that there are fewer metacharacters. The 'perlrequick' documentation says The special characters for a character class are "-]\^$" and are matched using an escape. No, I didn't "just know" that that's where the list of character class metacharacters was documented. I started with 'perlre', was somewhat surprised _not_ to find the list there, and then worked my way down the "SEE ALSO" at the bottom. Show quoted text
> However, trying to turn it into a character class as follows > > my ($dtfn) = $fn =~ m{([[:lower:]\d_\-[.]/]+)}mixs; >
The fact that the POSIX character classes use '[]' in their syntax does not mean that '[]' has the same meaning inside a character class as outside. It's a case of appearances being perhaps deceiving. Tom Wyant (putting in his $0.02 worth)
Since there has been no activity on this in over a year, and since the original request appears to me to be based on a misunderstanding of character classes, I'm going to mark this rejected.