|Perl Monk, Perl Meditation|
How do I test if a bit has been set in a bitstringby willk1980 (Novice)
|on Apr 25, 2013 at 02:07 UTC||Need Help??|
willk1980 has asked for the
wisdom of the Perl Monks concerning the following question:
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:
The definition for the different bits are:
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.