if ( defined $foo and $foo ne "bar") #### # depending on context my $foo = whatever() || ''; my $foo = whatever() || 0;