in reply to Simple Digests?

Page 237 of my copy of Programming Perl (2d edition) has this:

undef $/; # That's what's in the book; local $/ may be better. $checksum = unpack("%32C*",<>) %32767;
which is claimed to produce "the same number as the System V sum program".

This may be supercheap; it's certainly pretty short.

emc

" The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents."
—Nathaniel S. Borenstein

Replies are listed 'Best First'.
Re^2: Simple Digests?
by wazoox (Prior) on Mar 29, 2006 at 15:59 UTC
    funny, in perldoc -f unpack we have :
    For example, the following computes the same number as the Sys- tem V sum program: $checksum = do { local $/; # slurp! unpack("%32C*",<>) % 65535; };
    So it gained one more bit in the meanwhile :)

      That is funny. Now, I'm wondering why....

      emc

      "Being forced to write comments actually improves code, because it is easier to fix a crock than to explain it. "
      —G. Steele