Is there a way to give names to bits as in a byte bit field whose every bit would have a meaning that could be set by a subroutine, like:
setStatus(powerOn);
... which would set the powerOn bit in a 8-bit status byte. This bit could be the first one, bit 0. Then we could have:
setStatus(lightOn);
Which would set another status bit in the same status byte while not modifying the other set/unset bits. So on so forth.
Is there some kind of enum type in Perl to do that ? Or can it be done using a hash ?
Thanks.
In reply to Giving names to bits by carcassonne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |