```{index} single: dump; Digest::SHA function ``` ```{index} single: Digest::SHA::dump; Perl function ``` # 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 ```perl $sha->dump("hash.state"); $sha->dump; # to STDOUT ``` ## What you get back `1` on success (truthy), `undef` on I/O failure. ## Examples ```perl 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; ``` ```perl ## Debug-dump to the terminal: $sha->dump; ``` ```perl ## 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 `undef` rather than croaking. - Called on a non-`Digest::SHA` object, returns `undef`. ## Differences from upstream Fully compatible with upstream `Digest::SHA` {{ upstream.Digest_SHA }}. ## See also - `load` — counterpart that reads the file `dump` produces. - `getstate` — underlying text-state producer. - `putstate` — text-state ingester.