in reply to
testing defined($x) && length($x)
Given that the test will fail if either
$x
is undefined or is defined but is empty, you could avoid the
uninitialized value...
warning by using
if (length($x || '')) { ... }
[download]
A user level that continues to overstate my experience :-))
Comment on
Re: testing defined($x) && length($x)
Select
or
Download
Code
Replies are listed 'Best First'.
Re^2: testing defined($x) && length($x)
by
ikegami
(Patriarch)
on Mar 25, 2009 at 15:50 UTC
That introduces a false negative. The if's body is no longer executed when $x eq '0'.
[reply]
In Section
Seekers of Perl Wisdom