my $hex = "0x0000001b"; print BIN pack('H*', substr($hex,2));