The defined function checks if a variable is undef or not. This is different from being evaluated to true or false.

See also the explanation about boolean values in Perl.

          defined?      if ()

undef        no          no
0            yes         no
0.00         yes         no
''           yes         no
my @arr;     N/A         no
my %h;       N/A         no
1            yes         yes
'0'          yes         no
'00'         yes         yes