PDL::IO::Storable(3)

NAME
PDL::IO::Storable - helper functions to make PDL usable with serialisation packages

SYNOPSIS
  use Storable;
  use PDL::IO::Storable;
  $hash = {
            'foo' => 42,
            'bar' => zeroes(23,45),
          };
  store $hash, 'perlhash.dat';

  use JSON::MaybeXS;
  $encoder = JSON::MaybeXS->new(allow_tags => 1);
  my $ndarray = xvals (5,2);
  my $encoded_json = $encoder->encode ($ndarray);
  my $decoded_ndarray = $encoder->decode ($encoded_json);

DESCRIPTION
Serialisation packages such as "Storable", "Sereal", "JSON::MaybeXS" and "CBOR::XS" implement object persistence for Perl data structures that can contain arbitrary Perl objects. This module implements the relevant methods to be able to store and retrieve ndarrays via "Storable" as well as packages that support the Types::Serialiser protocol (currently Sereal, CBOR::XS and JSON packages).

Note that packages supporting the "Types::Serialiser" protocol need to have their respective flags enabled so that the FREEZE and THAW callbacks are used.

Note also that while JSON::MaybeXS is supported, if it has to fall back to JSON::PP, it will fail. JSON::XS treats the data it gets back from "FREEZE" as items to encode, while JSON::PP treats the list it gets as strings already encoded. They are fundamentally incompatible, so this module supports the JSON::XS option.

Finally, data flow is not preserved. If a data structure containing ndarrays connected by data flow is serialised then this will need to be explicitly reinstated on deserialisation.

FUNCTIONS

  store
store an ndarray using Storable

  $x = random 12,10;
  $x->store('myfile');

  freeze
freeze an ndarray using Storable

  $x = random 12,10;
  $frozen = $x->freeze;

AUTHOR
Copyright (C) 2013 Dima Kogan <dima@secretsauce.net> Copyright (C) 2002 Christian Soeller <c.soeller@auckland.ac.nz> All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file.