develooper Front page | perl.perl5.porters | Postings from July 2010

[perl #5087] used only once warning

Thread Previous
From:
George Greer via RT
Date:
July 28, 2010 18:43
Subject:
[perl #5087] used only once warning
Message ID:
rt-3.6.HEAD-11314-1280367798-446.5087-15-0@perl.org
On Sat Jul 23 01:55:34 2005, schwern wrote:
> > [dha@panix.com - Fri Jan 05 01:38:47 2001]:
> >
> > Maybe there's a reason for it, but...
> > 
> > ~ 12:35:18$ perl -wce '$count = 1;'
> > Name "main::count" used only once: possible typo at -e line 1.
> > -e syntax OK
> > 
> > BUT...
> > 
> > ~ 12:35:52$ perl -wce 'my $count = 1;'
> > -e syntax OK
> > 
> > Shouldn't that warning be raised, regardless of scope?
> 
> I agree.  In fact the argument for the warning is even stronger for a
> lexical.  A global seen only once... well maybe some other package grabs
> at it.  But a lexical declared but never used is useless.
> 
> About the only counter argument I can see is that issuing the warning
> for lexicals will cause a lot of existing code to start yelping.  But
> that's what warnings are for.  I for one would like to know about unused
> lexicals.
> 

There's a CPAN module for that:
http://search.cpan.org/dist/warnings-unused/

Requests to make this a core feature please make a separate ticket.

-- 
George Greer

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About