nstore_fd#
Serialise a referenced structure in network byte order and write it to an open filehandle.
Synopsis#
use Storable qw(nstore_fd fd_retrieve);
open my $fh, ">", "portable.bin" or die $!;
nstore_fd(\%data, $fh);
What you get back#
Returns 1 on success. Emits a length-prefixed payload — same
framing as store_fd — whose body is a portable (network-order)
serialisation. The matching reader is fd_retrieve, which
detects byte order automatically.
Examples#
Ship a record to a remote host over a pipe:
open my $out, ">&", \*STDOUT or die $!;
nstore_fd(\%payload, $out);
Edge cases#
First argument must be a reference; croaks with
Not a referenceotherwise.If the filehandle has no usable file descriptor, the call succeeds silently without writing. Check the handle first if that matters.
Differences from upstream#
Uses the same 4-byte little-endian length-prefix framing as
store_fd; upstream Storable does not. Pinned byt/81-xs-native/Storable/080-fd.t.
See also#
fd_retrieve— matching reader.store_fd— faster same-architecture variant.nstore— write portable bytes to a named file.nfreeze— return portable bytes instead of writing.