Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^2: How do I find out which variables I'm not using?by Aighearach (Initiate) |
on Nov 06, 2004 at 02:30 UTC ( [id://405683]=note: print w/replies, xml ) | Need Help?? |
I'm no internals wizard, but I think you're right on the mark.
But more importantly, this is the correct behavior. The purpose of the warning is (presumably) a second line of defense behind strict, for detecting a mispelled variable names. It's purpose probably isn't to warn you that you didn't use it enough, but rather, that not using an undeclared variable means you may (probably do) have a typo. In the case of a my declared variable, You'll actually still get the warning if you typo it OTHER THAN in the my call. But if you're using my... shouldn't you also be using strict? I am curious as to the thought process that would lead to using only one of the two. Examples: Typo was still detected. Typo still detected. No warning. If it is a typo is questionable. It is like a program with no output; if it DOES anything is a matter for some philosophers. But it doesn't matter. Declaring an extra my var doesn't hurt anything. And if you group all your my calls together like my( $foo, $bar, $baz, ) then it doesn't even waste much time. On many systems, I doubt the difference would be measurable. And so even in all the examples given prior, the correct behavior of identifying harmful typos is always taken. Personally, I think it's terrible to write code without strict, when it's code that is important enough, or will last long enough, or is intricate enough, that warnings are needed or used. I would only recommend forgoing use strict on once-off one-liners (ie, system administration and playing around). -- Snazzy tagline here
In Section
Seekers of Perl Wisdom
|
|