Here is one method:
- tye (but my friends call me "Tye")my %bits; my @fields= qw( organization report poise hair swimsuit question bribe connections ); @bits{@fields}= map { 1<<$_ } 0..7; sub mask { my $mask= 0; $mask |= $bits{$_} for @_; return $mask; } my $byte= 0; foreach my $field ( keys %bits ) { $byte |= $bits{$field} if $obj->{$field} =~ /\S/; } # ... if( $byte & mask(qw( organization swimsuit question bribe )) == mask("organization") ) { # ... } elsif( $byte & ~mask("question") == mask("swimsuit") ) { # ... } else { die "Contestant cheated!\n"; }
In reply to (tye)Re: Building a byte to test truth table
by tye
in thread Building a byte to test truth table
by PsychoSpunk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |