Another approach:
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le
"my @strings = map pack('H*', $_), '30abff', 'ab30ff', '30', 'ab1a30';
dd \@strings;
;;
for my $bs (@strings) {
printf 'here: ';
my @bits = unpack '(B8)*', $bs;
print join '//', @bits;
}
"
["0\xAB\xFF", "\xAB0\xFF", 0, "\xAB\x1A0"]
here: 00110000//10101011//11111111
here: 10101011//00110000//11111111
here: 00110000
here: 10101011//00011010//00110000
Please see
pack,
unpack,
perlpacktut.
Update: Added another example string: '30abff'
Give a man a fish: <%-{-{-{-<