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:

$byte = ''; if ($obj->{organization} =~ /^\s*$/) { $byte .= '0'; } else { $byte .= '1'; } ... if ($obj->{report} =~ /^\s*$/) { $byte .= '0'; } else { $byte .= '1'; }
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:
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 }
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.

ALL HAIL BRAK!!!


In reply to Building a byte to test truth table by PsychoSpunk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.