Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: comparing two values under 'perl -w'

by RMGir (Prior)
on Apr 02, 2002 at 15:50 UTC ( [id://156033]=note: print w/replies, xml ) Need Help??


in reply to comparing two values under 'perl -w'

Interesting... Offhand, I can't think of anything, so I'd suggest:
sub equalOrBothNull { my ($a, $b) = @_; ((defined($a) && defined($b) && $a==$b) || (!defined($a) && !defined($b)); }
That way, you can at least hide the problem and make the main code more readable.

By the way, I'm pretty sure

not defined($a) && not defined($b)
is not what you want.
$ perl -MO=Deparse -e'not defined($a) && not defined($b)' not defined $a && !defined($b); -e syntax OK
Not doesn't bind as tightly as !.
--
Mike

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://156033]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2024-04-18 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found