Checksum Perl 
Author Message
 Checksum Perl

I have to write a procedure that creates a checksum of the characters
within a straight ascii file.  Could someone post some suggestions about
doing this?

Thanks
Brendan



Tue, 18 Jun 1996 06:06:52 GMT  
 Checksum Perl

Quote:
> I have to write a procedure that creates a checksum of the characters
> within a straight ascii file.  Could someone post some suggestions about
> doing this?

You need to use the unpack function.  The Perl man page contains the
info you're looking for:

             In addition, you may prefix a field with a %<number>
             to indicate that you want a <number>-bit checksum of

             the items instead of the items themselves.   Default
             is  a  16-bit  checksum.  For example, the following
             computes the same number as the System  V  sum  pro-
             gram:

                  while (<>) {
                      $checksum += unpack("%16C*", $_);
                  }
                  $checksum %= 65536;
--
Jay Rogers  -  Ampersand Inc.  Westford, Mass.  USA



Sat, 22 Jun 1996 21:50:40 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Checksum of perl program

2. perl checksum code

3. Fast BSD checksum in perl?

4. Perl Implementation of Checksum?

5. Need Pgp signature/checksum for Perl distribution

6. Calculate a file's checksum with Perl?

7. generating GCG sequence checksum via perl

8. File checksum module?

9. how do I save an MD5 checksum

10. Calculating checksums

11. checksum calculation for file offsets

12. 32 bits checksum calculation

 

 
Powered by phpBB® Forum Software