#!/usr/bin/perl use strict; use warnings; my $f = "31FCFFFFFFFFFFFE5817300618262527262123216E5D5346172D620000C00000000000000000262F2D2D2D2E2D00008000000150591200A832C001D026252222893360808026187CFF"; $f = pack("H*",$f); # substr EXPR,OFFSET,LENGTH,REPLACEMENT print "Number of bytes: ", length $f, "\n"; printf "record Len? : %x hex \n",ord(substr($f,0,1)); print "record Len? : ", ord(substr($f,0,1))," decimal \n"; print "not right first byte, ASCII '1':", substr($f,0,1),"\n"; ##ASCII "1"; __END__ Prints: Number of bytes: 73 record Len? : 31 hex record Len? : 49 decimal not right first byte, ASCII '1':1