use Compress::Zlib my $crc = 0; while ($fh->read($buffer)) { $crc = Compress::Zlib::crc32($buffer, $crc); }