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.

תקציר#

$sha->dump("hash.state");
$sha->dump;                   # to STDOUT

מה מוחזר#

1 on success (truthy), undef on I/O failure.

דוגמאות#

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";

מקרי קצה#

  • An unwritable path returns undef rather than croaking.

  • Called on a non-Digest::SHA object, returns undef.

הבדלים מן ה-upstream#

Fully compatible with upstream Digest::SHA 6.04.

ראו גם#

  • load - counterpart that reads the file dump produces.

  • getstate - underlying text-state producer.

  • putstate - text-state ingester.