in reply to Re^3: Perl equivalent of Java code
in thread Perl equivalent of Java code

Could you do me a favour and test to make sure it works for "FFFF", "000102" and "102"?

Replies are listed 'Best First'.
Re^5: Perl equivalent of Java code
by Anonymous Monk on Jan 20, 2006 at 03:46 UTC
    It works for 000102 and 102 but it dosent work for FFFF

    FFFF in java 0 -1 -1 the Perl one 15 -1 -16

      Oh good, Java works as expected. But you found a bug in my code! Fix:
      my $key = "0123456789ABCDEF0123456789ABCDEF"; local $_ = $key; s/^0+//; $_ = "0$_" if length() % 2 == 1; $_ = "00$_" if /^[89ABCDEFabcdef]/; my @b = unpack('c*', pack('H*', $_));