K
Klaus Sulzberger
Follwing function convert Hex to bin:
sub hex2bin
{
my $str=unpack("B32",pack("N",hex$_[0]));
$str=~s/^0+(?=\d)//;
return($str);
}
The problem of the function is, that the result cuts the zeros.
For examples:
Hex: 7D
Function result: 1111101
Want to have: 01111101
(for 1 Byte)
sub hex2bin
{
my $str=unpack("B32",pack("N",hex$_[0]));
$str=~s/^0+(?=\d)//;
return($str);
}
The problem of the function is, that the result cuts the zeros.
For examples:
Hex: 7D
Function result: 1111101
Want to have: 01111101
(for 1 Byte)