Kelly Jones am Dienstag, 19. Dezember 2006 01:49:
> perl -w dings me if I use a variable just once:
>
> Name "main::foo" used only once: possible typo...
>
> even if I'm magically defining/using $foo somewhere else.
>
> Is there any way to tag a variable to tell the -w option that I'm
> intentionally using that variable just once, and not to warn me about it?
>
> I realize I could do something like: "$foo = $foo" to force the issue,
> but that seems kludgy.
Is it really not possible to
use warings;
use strict; # <-- your friend!
my $foo=1; # <-- declare lexical var with 'my'
print $foo; # prints 1
?
Then use
use warnings;
{
no warnings 'once';
$foo=1;
}
print $foo; # prints 1
Dani
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>