Subject: | ProhibitLocalVars on localized hash entry |
Date: | Tue, 16 Jun 2009 07:52:34 +1000 |
To: | bug-Perl-Critic [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
I've had some success using "local" to make block-scoped hash value
settings, like flags on an object for recursion protection etc,
{
local $self->{'update_in_progress'} = 1;
...
}
It'd be good if ProhibitLocalVars allowed expressions like that (array
element, hash element, other sorts of dereference), on the basis the aim
of the policy is to pick up places which ought to be "my" instead of
"local".
(Or alternatively, if the above is a bad idea then further notes in the
docs about why the policy is flagging it ...)
Index: ProhibitLocalVars.run
===================================================================
--- ProhibitLocalVars.run (revision 3341)
+++ ProhibitLocalVars.run (working copy)
@@ -27,6 +27,8 @@
local $SIG{HUP} \&handler;
local $INC{$module} = $path;
+local $self->{'update_in_progress'} = $path;
+
#-----------------------------------------------------------------------------
##############################################################################