nstore_fd#

Serialise a referenced structure in network byte order and write it to an open filehandle.

תקציר#

use Storable qw(nstore_fd fd_retrieve);
open my $fh, ">", "portable.bin" or die $!;
nstore_fd(\%data, $fh);

מה מוחזר#

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.

דוגמאות#

Ship a record to a remote host over a pipe:

open my $out, ">&", \*STDOUT or die $!;
nstore_fd(\%payload, $out);

מקרי קצה#

  • First argument must be a reference; croaks with Not a reference otherwise.

  • If the filehandle has no usable file descriptor, the call succeeds silently without writing. Check the handle first if that matters.

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

  • Uses the same 4-byte little-endian length-prefix framing as store_fd; upstream Storable does not. Pinned by t/81-xs-native/Storable/080-fd.t.

ראו גם#

  • 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.