dump#
Write the current Digest::SHA state to a file or STDOUT in text form.
With a filename argument, writes the text produced by getstate to
that file, truncating it if it exists. Without an argument, prints the
same text to STDOUT. The companion load method reads it back.
Synopsis#
$sha->dump("hash.state");
$sha->dump; # to STDOUT
What you get back#
1 on success (truthy), undef on I/O failure.
Examples#
my $sha = Digest::SHA->new(256);
$sha->add("partial");
$sha->dump("checkpoint.state");
## ... later, perhaps in another process ...
my $resumed = Digest::SHA->load("checkpoint.state");
$resumed->add("tail");
print $resumed->hexdigest;
## Debug-dump to the terminal:
$sha->dump;
## Check the return value for I/O errors:
defined $sha->dump("/nonexistent/path/file")
or warn "could not write state";
Edge cases#
An unwritable path returns
undefrather than croaking.Called on a non-
Digest::SHAobject, returnsundef.
Differences from upstream#
Fully compatible with upstream Digest::SHA 6.04.
See also#
load— counterpart that reads the filedumpproduces.getstate— underlying text-state producer.putstate— text-state ingester.