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

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

am 29.03.2008 13:35:40 von Gunnar Hjalmarsson

Thrill5 wrote:
> "Tomasz Chmielewski" wrote in message
> news:fsie2l$g0f$1@online.de...
>> 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.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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

am 29.03.2008 16:41:45 von Tomasz Chmielewski

Gunnar Hjalmarsson schrieb:
> Thrill5 wrote:
>> "Tomasz Chmielewski" wrote in message
>> news:fsie2l$g0f$1@online.de...
>>> 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