open the file set binmode while (not EOF) { read N-bytes of the file into a buffer # don't want to read the whole file into memory if it's a big file Digest::SHA::add($buffer) } close file