in reply to Re^2: Defined vs ne ""
in thread Defined vs ne ""

It seems to me that you should simply initialize your variables up front. IE: my $test = '';

Then you don't have to worry about undefined values, and string compares with the empty string will do what you want.