my $input = pack 'H*', "your binary input unpacked with 'H*'"; my ($messageType,$ProtoOrVer,$MsgLen,$MsgSeqNum,$ClOrdID,$OnBehalfOfCompID,$rest) =unpack "A A n N N2 A*",$sourceMsg}; print ... print "expected output\n";