my $hexstr = '0015070400a4'; my $raw =pack('H*',$hexstr); $hexstr=unpack('H*',$raw);