in reply to Re^6: regex return true instead of false (precedence)
in thread regex return true instead of false
I was trained as a hardware engineer. DeMorgan's Theorem is an important part of hardware design. An AND or an OR gate is actually pretty rare. The most common gate is NAND, followed by NOR. The reason for that is that the fastest gates have a logical inversion - that is due to the way the hardware works. Inverting that output slows things down.unless ( (!($args =~ /\-rs(\s+)(\S+)/)) && (!($args =~ /\-p(\s+)(\S+)/)) && (!($args =~ /\-P(\s+)(\S+)/)) ) {..... # I figure this is easier to understand: if ( $args =~ /\-rs(\s+)(\S+)/ #update changed unless->if or $args =~ /\-p(\s+)(\S+)/ or $args =~ /\-P(\s+)(\S+)/ ) {....
Changing the formulation of condition can make things easier to understand. The compiler should generate similar code for the above examples. I just think that the second is easier for a human to understand.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: regex return true instead of false (precedence)
by AnomalousMonk (Archbishop) on Aug 27, 2019 at 03:49 UTC | |
by GrandFather (Saint) on Aug 27, 2019 at 07:18 UTC | |
by AnomalousMonk (Archbishop) on Aug 27, 2019 at 14:27 UTC | |
by Marshall (Canon) on Aug 27, 2019 at 23:27 UTC |