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

People
Owner: Nobody in particular
Requestors: victor [...] vsespb.ru
Cc:
AdminCc:

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



Subject: local $_ uninitialized
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.13-2422-1373746510-1215.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 452
Download (untitled) / with headers
text/plain 452b
"local" variable not initialized at line 7, column 2. See page 78 of PBP. (Severity: 3) for this PoC: ================ use strict; use warnings; sub mysub { my $sum = 0; local $_; while(<DATA>) { chomp; $sum += $_; } return $sum; } for (10, 20) { print $_ + mysub(); } __DATA__ 1 2 3 ================ (above code will die without "local $_") I think it's perfectly sane to declare some special variables uninitialized - $_, $@, $! etc.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.13-2422-1373746510-1215.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.13-2422-1373746510-1215.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.16-10062-1380256452-769.86912-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 287
Download (untitled) / with headers
text/plain 287b
On Sat Jul 13 13:15:10 2013, vsespb wrote: Show quoted text
> I think it's perfectly sane to declare some special variables > uninitialized - $_, $@, $! etc.
I'm not disagreeing with you, but I don't see the purpose of localizing $_ at all in this bit of code. Can you help me understand your example?
MIME-Version: 1.0
In-Reply-To: <rt-4.0.16-10062-1380256452-769.86912-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.13-2422-1373746510-1215.0-0-0 [...] rt.cpan.org> <rt-4.0.16-10062-1380256452-769.86912-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.16-10067-1380258879-1640.86912-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 171
Download (untitled) / with headers
text/plain 171b
I think I understand now. See also https://rt.cpan.org/Ticket/Display.html?id=84734 -- Jeffrey Thalhammer Imaginative Software Systems www.imaginative-software.com


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.