You want to look into vec.
$type = vec($entry,0,8) & 191; [download]
In reply to Re^3: Binary Reading Questions by idsfa in thread Binary Reading Questions by Eyeth