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

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

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



Subject: "local" variable not initialized (possibly false positive $_)
"local" variable not initialized at line 5, column 1. See page 78 of PBP. 1 #!/usr/bin/perl 2 use strict; 3 use English; 4 5 local $_; 6 The variable "$_" is a special case and doe snot need initialization.
Subject: Re: [rt.cpan.org #56620] "local" variable not initialized (possibly false positive $_)
Date: Thu, 15 Apr 2010 07:56:30 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
On 4/15/10 4:06 AM, Jari Aalto via RT wrote: Show quoted text
> "local" variable not initialized at line 5, column 1. See page 78 of > PBP. > > 1 #!/usr/bin/perl > 2 use strict; > 3 use English; > 4 > 5 local $_; > 6 > > The variable "$_" is a special case and doe snot need initialization.
No, it isn't a special case.
On Thu Apr 15 08:56:43 2010, clonezone wrote: Show quoted text
> On 4/15/10 4:06 AM, Jari Aalto via RT wrote:
> > "local" variable not initialized at line 5, column 1. See page 78 of > > PBP. > > > > 1 #!/usr/bin/perl > > 2 use strict; > > 3 use English; > > 4 > > 5 local $_; > > 6 > > > > The variable "$_" is a special case and does not need
initialization. Show quoted text
> > No, it isn't a special case.
Care to elaborate more. I vaguely remember that almost every Perl book and manual page say that "$_" is special and it is set specifically by Perl's built-in functions. An example, clean and simple (less is more): local $_; while ($_ = pop @array) { ... } Not horrids like: local $_ = ""; while ($_ = pop @array) { ... } My, that code emits: # Quotes used with an empty string at line 1, near 'local $_ = ""; ValuesAndExpressions::ProhibitEmptyQuotes So it needs ever more horrid: local $_ = undef; while ($_ = pop @array) { ... } Not treating the $_ with a proper care can lead these kind of uglies when people actually believe Perl::Critic's output. It could be made more smart with respect to $_
Subject: Re: [rt.cpan.org #56620] "local" variable not initialized (possibly false positive $_)
Date: Wed, 21 Apr 2010 20:15:36 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
On 4/15/10 9:07 AM, Jari Aalto via RT wrote: Show quoted text
> So it needs ever more horrid: > > local $_ = undef;
You may consider that ugly, but that's /precisely/ what Conway wants you to do.