|
Prev: using LWP to POST data via "javascript:document.form.submit()" link
Next: How to read a perl script from withink itself
From: gsarup on 5 Jan 2006 17:25 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 5 Jan 2006 17:35 <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 6 Jan 2006 11:52
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 |