```{index} single: retrieve; Storable function ``` ```{index} single: Storable::retrieve; Perl function ``` # retrieve Read a frozen structure from a named file and reconstruct it. ## Synopsis ```perl use Storable qw(store retrieve); my $data = retrieve("cache.bin"); ``` ## What you get back A reference of the same kind that was passed to `store` or `nstore`. Byte order is auto-detected, so one `retrieve` works for files written by either producer. ## Examples Reload a persisted cache on process start: ```perl my $cache = -e "cache.bin" ? retrieve("cache.bin") : {}; ``` Consume a file produced by `nstore` on another machine: ```perl my $payload = retrieve("incoming.bin"); ``` ## Edge cases - If the file cannot be opened, croaks with `Storable: can't open file for reading`. - Empty or corrupt files croak with an explicit "not valid Storable data" message. - A partial read (network interruption, truncated file) is reported as corrupt, never returned as a half-built structure. ## Differences from upstream - Only accepts files written by pperl's `store` / `nstore`. Files produced by perl5's `Storable::store` are rejected as corrupt. Pinned by `t/81-xs-native/Storable/030-store-retrieve.t`. ## See also - `store` — matching writer for native-order payloads. - `nstore` — matching writer for portable payloads. - `fd_retrieve` — read from an open filehandle. - `file_magic` — inspect the file's header without thawing.