Anno Siegel wrote:
> fifo <> wrote in comp.lang.perl.misc:
>
>>Isn't this just the same as doing
>>
>> my $chksum = unpack("H*",$string);
>>
>>as unpack "H*" is only going to give you a single scalar anyway?
>
>
> We're not talking "H*" but "%H*". There's a *bug*, and it doesn't
> behave according to specification.
>
> Please read for comprehension.
>
> Anno
I don't think I follow either
take:
my $string = 'ThisIsAString';
# PERFORM PLAIN UNPACK
my $chksum = unpack("H*",$string)."\n";
print $chksum."\n";
gives:
54686973497341537472696e67
try:
my $string = 'ThisIsAString';
# PERFORM CHECKSUM UNPACK
my $chksum = unpack("%H*",$string);
print $chksum."\n";
gives:
0
as discussed
try suggested workaround:
my $string = 'ThisIsAString';
# PERFORM WORKAROUND CHECKSUM UNPACK
my ($chksum) = unpack("%H*",$string);
print $chksum."\n";
gives:
54686973497341537472696e67
which is the same result as the plain unpack and not the checksum sought.