Hi,
I've got a filename which contains some flags about the file stored as a bitstring. I can extract the bitstring from the filename, but I can't seem to work out how to test if a particular bit is set or not.
The files are stored as:
<filename>.<bitstring>
e.g. mymessage.1004
The definition for the different bits are:
FLAG_DELETED 0x0001 FLAG_DRAFT 0x0002 FLAG_SEEN 0x0004 FLAG_RECENT 0x0008 FLAG_FLAGGED 0x0010 FLAG_ANSWERED 0x0020 FLAG_SAVED 0x0040 FLAG_MDNSENT 0x0080 FLAG_STTPENDING 0x0100 FLAG_FAVOURITE 0x0200 FLAG_NOTIFY 0x0400 FLAG_STTPRESENT 0x0800 FLAG_STTCOMPLETE 0x1000
All integers are expressed in hex format. So if I have the following "1004", that means the SEEN flag and the STTCOMPLETE flag have been set.
I'm trying to test if the FAVOURITE flag has been set, but I don't really understand how to do it. I see posts online about unpacking the bits using the perl unpack function, but I'm not sure how to use it.
I'm sure this is trivial, but I'm still relatively new to perl and writing software, so please be kind.
In reply to How do I test if a bit has been set in a bitstring by willk1980
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |