- or download this
$ perl -e'print pack "H*", "abc";' | od -t x1
0000000 ab c0
...
$ perl -e'print pack "H*", "abc0";' | od -t x1
0000000 ab c0
0000002
- or download this
my $bin = pack("H*", ( length($hex) % 2 ? '0' : '' ).$hex);
...
( my $hex = unpack('H*', $bin) ) =~ s/^0+(?!\z)//;
- or download this
my $bin = pack("H*", "".reverse $hex);
...
( my $hex = reverse unpack('H*', $bin) ) =~ s/^0+(?!\z)//;
- or download this
my $bin = pack("NH*", length($hex), $hex)
...
my ($length, $hex) = unpack('NH*', $bin);
substr($hex, $length, length($hex), '');