Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!samsung!uunet!zephyr.ens.tek.com!orca.wv.tek.com!pogo!andyd From: andyd@pogo.WV.TEK.COM (Andy Davidson) Newsgroups: comp.lang.perl Subject: Unpack checksum doesn't match BSD sum Message-ID: <10911@pogo.WV.TEK.COM> Date: 19 May 91 22:55:08 GMT Reply-To: andyd@pogo.WV.TEK.COM (Andy Davidson) Distribution: na Organization: Tektronix, Inc., Wilsonville, OR. Lines: 43 Newsgroups: comp.perl Subject: unpack & checksum Expires: References: Sender: Reply-To: andyd@pogo.WV.TEK.COM (Andy Davidson) Followup-To: Distribution: usa Organization: Tektronix, Inc., Wilsonville, OR. Keywords: I am trying to use the snippet of code in the man page to use the unpack function to generate a 16-bit checksum, i.e., while (<>) { $checksum += unpack("%16C*",$_); } $checksum %= 65536; printf "%ld\n", $checksum; I also tried the version shown in the Camel book: undef $/; $checksum = unpack("%16C*", <>); printf "%ld\n", $checksum; However, these report different results than sum does, either on my 4.3BSD VAX or a Sun running SunOS 4.1. Why? Is there a difference between what System V 'sum' reports and what BSD 'sum' reports? Or am I doing something wrong? I am currently running version 4.0 patchlevel 3. andy -- Andy Davidson 503-685-3033 Manager, Tektronix/GPID QA & Tools Internet: andyd@pogo.WV.tek.com uucp: ...!tektronix!pogo!andyd Trust, but verify!