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

People
Owner: Nobody in particular
Requestors: EDAVIS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.118
Fixed in: (no value)



Subject: Reused variable name in lexical scope: $_
Download (untitled) / with headers
text/plain 519b
Variables::ProhibitReusedNames should not include $_ in its check, since that variable is special and you cannot just 'invent unique variable names' for it as the message suggests. Whether lexically-scoped $_ should be used at all is a matter for a different policy. Here is a test case which I suggest should not warn: #!/usr/bin/perl # $Id: $ use 5.014; use warnings; use strict; our $VERSION = 1; foreach my $x ( 'a', 'b', 'c' ) { my $_ = $x; foreach my $y ( 'x', 'y', 'z' ) { my $_ = $y; } }
Download (untitled) / with headers
text/plain 746b
On Thu Sep 06 08:20:00 2012, EDAVIS wrote: Show quoted text
> Variables::ProhibitReusedNames should not include $_ in its check, since > that variable is special and you cannot just 'invent unique variable > names' for it as the message suggests. > > Whether lexically-scoped $_ should be used at all is a matter for a > different policy. > > Here is a test case which I suggest should not warn: > > #!/usr/bin/perl > # $Id: $ > use 5.014; > use warnings; > use strict; > our $VERSION = 1; > foreach my $x ( 'a', 'b', 'c' ) { > my $_ = $x; > foreach my $y ( 'x', 'y', 'z' ) { > my $_ = $y; > } > }
(A little off-topic, but this is what I think of lexical $_: my $_; write; format = @<<<<<<. $@, scalar sub { eval { reverse } }->() . :-)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.