Musar Corporation wrote, on Thursday, February 12, 2004 8:57 AM : I had some code that was giving me trouble. I wanted a program to : perform some function as long as two conditions did not exist. My : original code was: : : if ($some_value ne $some_input_value && $another_value ne : $another_input_value) { : : do something; : : } : : I fixed the problem by changing it to: : : unless ($some_value eq $some_input_value && $another_value eq : $another_input_value) { : : do something; : : }
Brush up on your Boolean logic. When you distribute (or "factor out") not from "and" or "or", the sense changes. That is: (Not A And Not B) is equivalent to Not (A Or B). Look at the truth tables (something I do a lot when trying to reduce a complicated conditional): A B !A&&!B A||B 1 1 0 1 1 0 0 1 0 1 0 1 0 0 1 0 What you started with was !A && !B ("as long as two conditions did not exist", so the expression was a correct translation of your English requirement); since you wanted the latter, your English requirement should have been something like "as long as both conditions weren't met." Good luck Joe ============================================================== Joseph P. Discenza, Sr. Programmer/Analyst mailto:[EMAIL PROTECTED] Carleton Inc. http://www.carletoninc.com 574.243.6040 ext. 300 fax: 574.243.6060 Providing Financial Solutions and Compliance for over 30 Years ***** Please note that our Area Code has changed to 574! ***** _______________________________________________ Perl-Win32-Web mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs