Another option is to local $/ = \1_048_576; to read the first 1MB:
use strict; use warnings; use Digest::MD5 qw/md5_hex/; my $md5_hex_1m = file_md5_hex_1m('File.txt'); print $md5_hex_1m; sub file_md5_hex_1m { my ( $file, $contents ) = @_; local $/ = \1_048_576; open my $fh, '<', $file or die $!; return Digest::MD5->new()->add($contents)->hexdigest if defined( $contents = <$fh> ); }
In reply to Re: Hash only portion of a file
by Kenosis
in thread Hash only portion of a file
by myforwik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |