|go ahead... be a heretic|
How do I find out which variables I'm not using?by amyoungil (Initiate)
|on Nov 06, 2004 at 00:07 UTC||Need Help??|
amyoungil has asked for the wisdom of the Perl Monks concerning the following question:
I tried defining $moosie, then never using it, to see if it would throw a warning, but it didn't. I thought that it used to do that? Maybe I'm wrong. I am using -w....
I'd like to know this so I can clean up my programs.
From MonkDan at UI:
$ perl -V:version version='5.8.3';
$ perl -e '$moosie = 42'
$ perl -we '$moosie = 42' Name "main::moosie" used only once: possible typo at -e line 1.
$ perl -We '$moosie = 42' Name "main::moosie" used only once: possible typo at -e line 1.
$ perl -We 'my $moosie = 42'
It looks like if you use `my', you can't find out which ones you aren't using.