Re: empty variables - getting rid of "uninitialized value" warnings?



Gunnar Hjalmarsson schrieb:
Thrill5 wrote:
"Tomasz Chmielewski" <tch@xxxxxxxxxxxxxxxxxxxx> wrote in message news:fsie2l$g0f$1@xxxxxxxxxxxx
How can I get rid of warnings if I make tests with "if" and some variables are empty?

Should I just ignore it? Or use "no warnings" just for that piece of code throwing a warning?

Try:
use strict;
use warnings;
no warnings 'uninitialized';

This will turn off only the uninitialized variable warnings, and keep all the other warnings. I find those warnings are more trouble to get rid of then the value that the warning provides.

Even if that may be true in some cases, it's not true in this case IMO. If you write code that does not generate such warnings, you increase the chance that there are no bugs. The OP has already received a few suggestions.

Also, if you want to disable 'uninitialized' warnings, you'd better do so in the block(s) where it's needed, and not disable them for the whole program.

Thanks all in this thread for useful suggestions!


--
Tomasz Chmielewski
http://wpkg.org


.



Relevant Pages