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
"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.
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?
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