in reply to Hex/binary/Decimal

The following code gives the desired result for your input:
sub hexstring2num { my $n = hex($_[0]); return ($n >> 5) & 0x1f; }