kappa has asked for the wisdom of the Perl Monks concerning the following question:
The task is to compare two variables in such a way that if they are both undef, then they should be treated as equal.
($a == $b) gives me warning about using undefined values.
(defined($a) && defined($b) && $a == $b) is wrong
This is used to detect changes in a database. This leads to the requirement that NULL must be equal NULL (which isn't right in the general case of course).
($a == $b) gives me warning about using undefined values.
(defined($a) && defined($b) && $a == $b) is wrong
is ugly.((defined($a) && defined($b) && $a == $b) || (not defined($a) && not defined($b))
This is used to detect changes in a database. This leads to the requirement that NULL must be equal NULL (which isn't right in the general case of course).
Back to
Seekers of Perl Wisdom