in reply to bit-wise

I think that I would splurge a little on memory and use a hash (or maybe an array if the names are really '1' .. '9'). All the operations you want are easy and straightforward with a hash:

my %state; @state{1..9}=();
  1. have name, clear bit
    $state{$name} = undef;
  2. have name(s), set bit(s)
    @state{@names} = (1) x @names;
  3. get count of set bits
    my $count = grep {$_} values %state;
  4. have one set bit, get its name
    my $setname = (grep {$state{$_}} keys %state)[0];
  5. have multiple set bits, get names (debugging only)
    my @setnames = grep {$state{$_}} keys %state;
  6. bit-wise logical ops, OR, AND, ...
    # same as ordinary perl print $foo if $state{$one} && $state{$tother};
A small hash like this isn't going to break the bank, and the perl operations to maintain it are much simpler than bit-twiddling.

Fixed typo in #2, thanks blokhead++

After Compline,
Zaxo