in reply to Using pack to evaluate text strings as hexadecimal values
In addition to using hex instead of pack, you need to change if($value && $MSG_FLAG_READ) { into if($value & $MSG_FLAG_READ) {
perlop