I am trying to write a sub to split up a string of hexadecimal numbers into pairs of two hex digits, then print their 8-bit binary representation. Obviously, I don't understand how pack is supposed to work. Why isn't this printing out the proper binary representations of these numbers? sub bittify{ my $string = pop; my @cols = (); # Split the string into individual hex numbers while (my $num = substr $string, 0, 2, ''){ print $num, "\n"; print unpack('b8', hex($num)), "\n"; } } my $string1 = "001fffaa"; bittify($string1); OUTPUT: 00 00001100 1f 11001100 ff 01001100 aa 10001100