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: 72910
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: rjray [...] blackperl.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.116
Fixed in: 1.117



Subject: False-positive of Variables::ProhibitPunctuationVars when {} used in interpolated string
Using a critic RC file that includes: [Variables::ProhibitPunctuationVars] allow = $@ $! $$ $0 $? $^O The attached file generates a complaint at line 7: Magic punctuation variable used in interpolated string at line 7, column 7. See page 79 of PBP. (Severity: 2) It is complaining about the construct "${$}" used in the string, to allow a literal trailing "_" (without interpreting this as dereferencing $_). Note that the line above has "$$" and generates no complaint. Randy -- Randy J. Ray rjray@blackperl.com randy.j.ray@gmail.com
Subject: test.pl
#!/usr/bin/env perl use strict; use warnings; print "This string contains the PID: $$\n"; print "This string contains the PID twice: ${$}_$$\n"; exit;
On Fri Dec 02 18:32:34 2011, RJRAY wrote: Show quoted text
> Using a critic RC file that includes: > > [Variables::ProhibitPunctuationVars] > allow = $@ $! $$ $0 $? $^O > > The attached file generates a complaint at line 7: > > Magic punctuation variable used in interpolated string at line 7, column > 7. See page 79 of PBP. (Severity: 2) > > It is complaining about the construct "${$}" used in the string, to > allow a literal trailing "_" (without interpreting this as dereferencing > $_). Note that the line above has "$$" and generates no complaint. > > Randy
Thank you for your report. The original form of this policy only considered variables outside of interpolated strings, since that is all PPI considers. When the policy was enhanced to consider variables embedded in interpolated strings, the bracketed forms of the variable names were not considered. The interpolated-string logic works on regular expressions, so the '${' in "${$}" was completely ignored. But then it found '$}', which is in the policy's list of punctuation variables, and Perl too apparently, though I have no idea what it does and I found no help in perlvar. The above may actually be an argument for adding the name of the offending variable to the message. The position reported is not very helpful in this case, since it is merely the position of the interpolated string. I am working on a patch to beef up the regular expression, but it is not as of this writing ready to be committed (self-compliance issues). Tom
Patch committed as SVN revision 4097.