From: gsarup on
Thanks Anno,

The relevant code is given below:

while($tail=<DISTFILE>)
{
$chk=substr($tail,17,6);
print "chk = $chk\n";
$chksum=$chksum+$chk;
}

$chksum=sprintf("%015d", $chksum);

Thanks
Gaurav

From: Anno Siegel on
<gsarup(a)gmail.com> wrote in comp.lang.perl.misc:
> Thanks Anno,
>
> The relevant code is given below:
>
> while($tail=<DISTFILE>)
> {
> $chk=substr($tail,17,6);
> print "chk = $chk\n";
> $chksum=$chksum+$chk;
> }
>
> $chksum=sprintf("%015d", $chksum);

There you go. If $chksum is >= 2**31 (about 5000 six-digit numbers)
you'll see wrong results. "%015.0f" will show the correct sums.

Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
From: Glenn Jackman on
At 2006-01-05 05:15PM, gsarup(a)gmail.com <gsarup(a)gmail.com> wrote:
> $chksum=$chksum+$chk;

Did you know you can write that as:
$chksum += $chk;

--
Glenn Jackman
Ulterior Designer