```{index} single: load; Digest::SHA function ``` ```{index} single: Digest::SHA::load; Perl function ``` # load Construct a `Digest::SHA` object from a text state file written by `dump`. Reads the file, parses its contents as a text state string, and returns a new object with the algorithm and internal state recorded in the file. Typically called as a class method, but works as an instance method too (the receiver is ignored; a fresh object is always returned). ## Synopsis ```perl my $sha = Digest::SHA->load("hash.state"); ``` ## What you get back A `Digest::SHA` object on success, `undef` if the file could not be read or the contents could not be parsed. ## Examples ```perl my $sha = Digest::SHA->new(256); $sha->add("one"); $sha->dump("hash.state"); my $resumed = Digest::SHA->load("hash.state"); $resumed->add("two"); print $resumed->hexdigest; ## same as Digest::SHA->new(256)->add("one")->add("two")->hexdigest ``` ```perl ## Missing file returns undef rather than croaking: my $sha = Digest::SHA->load("/does/not/exist"); print defined $sha ? "ok" : "undef"; # undef ``` ```perl ## Works as an instance method too (but still returns a fresh object): my $dummy = Digest::SHA->new(1); my $sha = $dummy->load("hash.state"); ``` ## Edge cases - I/O failure or a parse error returns `undef`. - The returned object's algorithm comes from the file, not from any receiver — the receiver is essentially a namespace hook. ## Differences from upstream Fully compatible with upstream `Digest::SHA` {{ upstream.Digest_SHA }}. ## See also - `dump` — writes the file `load` reads. - `putstate` — parses the text state directly from a string. - `_putstate` — binary-state counterpart.