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 $_