Article View: comp.lang.perl.misc
Article #286Calculate a file's checksum with Perl?
From: Alfonso PALACIOS SUREDA
Date: Thu, 20 Jan 2000 00:00
Date: Thu, 20 Jan 2000 00:00
22 lines
1245 bytes
1245 bytes
I would like to calculate a file's checsum using Perl. Ine the Perl doc
they say:
==========================
For example, the following computes the same number as the System V sum
program:
while (<>) {
$checksum += unpack("%16C*", $_);
}
$checksum %= 65536;
==========================
But when I try this, the checksum I get is slightly different from the
one I get whith the "sum" command on my Solaris platform.
- Can I still use this number as a checksum, like System V's?
- What do the 'pack' and 'unpack' functions do, anyway? They don't say
much in the Perl doc.
Thanx,
Alfonso
Technical Details
Message-ID:
<388720EF.D7364F8@alcatel.fr>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 112333,e5f5de2a0ef43657,start X-Google-Attributes: gid112333,public X-Google-Thread: fa0ae,e5f5de2a0ef43657,start X-Google-Attributes: gidfa0ae,public From: Alfonso PALACIOS SUREDA <alfonso.palacios-sureda@alcatel.fr> Subject: Calculate a file's checksum with Perl? Date: 2000/01/20 Message-ID: <388720EF.D7364F8@alcatel.fr> X-Deja-AN: 575279222 Content-Transfer-Encoding: 7bit Organization: Alcanet International France X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.perl.misc,fr.comp.lang.perl