note
kudra
I like to keep warnings on, because sometimes it is a bug when a variable is undefined, and I can't always rely on strict to tell me (for instance if I typo a hash key).
<p>
Other times I expect that a variable could be undefined. In those instances, I explicitly allow for that option:
<code>
if (defined($hash{key}) && $hash{key} =~ /\d+/) {
...
}
</code>
Other times I will set the variable to a false but defined value, such as an empty string or zero. It depends upon the context; often false and undefined are logically interchangeable, but other times they are not (in the above example, 0 has a different meaning than undef).
<p>
It doesn't hurt to be explicit about your expectations; it can make things easier for the next person.
551296
551296