PsychoSpunk has asked for the wisdom of the Perl Monks concerning the following question:
Greetings,
I've got what may amount to a simple question, but I cannot recall seeing anything like this before around here. (And I will admit that I'm not quite sure what other words to send into the search box to fully find anything even mildly related.)
So, here's my current code:
Extra details, the ... represents 6 more statements like the ones I have entered. All 8 checks are done to build a byte to check against a truth table as such:$byte = ''; if ($obj->{organization} =~ /^\s*$/) { $byte .= '0'; } else { $byte .= '1'; } ... if ($obj->{report} =~ /^\s*$/) { $byte .= '0'; } else { $byte .= '1'; }
What I want to do, is (unless I'm doing it the most efficient way, which I don't think I am) find a better way to build that byte. Nonetheless, I figured it would be nice to see a real world application of discrete mathematics.if ($byte =~ /1(0|1){3}0{3}(0|1)/) { do more checks against database } elsif ($byte =~ /0{4}1(0|1)0{2}/) { do other checks against database } else { produce error message }
ALL HAIL BRAK!!!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Building a byte to test truth table
by chromatic (Archbishop) on Nov 02, 2000 at 01:52 UTC | |
(tye)Re: Building a byte to test truth table
by tye (Sage) on Nov 02, 2000 at 01:52 UTC | |
(jcwren) RE: Building a byte to test truth table
by jcwren (Prior) on Nov 02, 2000 at 01:53 UTC | |
by dws (Chancellor) on Nov 02, 2000 at 08:25 UTC | |
by PsychoSpunk (Hermit) on Nov 03, 2000 at 05:25 UTC | |
by PsychoSpunk (Hermit) on Nov 02, 2000 at 02:03 UTC | |
Re: Building a byte to test truth table
by AgentM (Curate) on Nov 02, 2000 at 01:41 UTC | |
RE: Building a byte to test truth table
by dchetlin (Friar) on Nov 02, 2000 at 02:23 UTC |
Back to
Seekers of Perl Wisdom