in reply to Turn off warning for undefined value in comparison?
I really don't like to write...
Why not? It can help you remember context of a var and whether or not it may be undefined at that point.
I would use:
if ( defined $foo and $foo ne "bar")
to remind myself that $foo could be undefined, or, when assigning $foo:
# depending on context my $foo = whatever() || ''; my $foo = whatever() || 0;
provided $foo as an empty string/zero is not going to cause you problems. If $foo could be valid as either in a comparison, you need to go the define route (or turn off warnings - yuck!).
.02
cLive ;-)
|
|---|