Data::Transform::Reference - freeze and thaw arbitrary Perl data
use YAML; use Data::Transform::Reference; my $filter = Data::Transform::Reference->new( serialize => YAML->can('Dump'); deserialize => YAML->can('Load'); ); ... my $string = $filter->put($some_var); ... my $other_var = $filter->get($serialized_var);
Data::Transform::Reference allows programs to send and receive arbitrary Perl data structures without worrying about a line protocol. Its put() method serializes Perl data into a byte stream suitable for transmission. get_one() parses the data structures back out of such a stream.
Data::Transform::Reference implements the standard Data::Transform API. Only the differences are documented here.
new() creates and initializes a Data::Transform::Reference object. It requires the following parameters:
A code ref used to serialize data. Good candidates for this are nfreeze() from Storable or Dump() from a YAML implementation.
A code ref used to de-serialize data. Good candidates for this are thaw() from Storable or Load() from a YAML implementation.
Both code references are expected to accept a single parameter containing the data on which to act on.
Please see Data::Transform for documentation regarding the base interface.
It's important to use identical serializers on each end of a connection. Even different versions of the same serializer can break data in transit.
Most (if not all) serializers will rebless data at the destination, but many of them will not load the necessary classes to make their blessings work.
The original Reference filter was contributed by Artur Bergman, with changes by Philip Gwyn. Martijn van Beers simplified the API when starting Data::Transform
To install Data::Transform, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Transform
CPAN shell
perl -MCPAN -e shell install Data::Transform
For more information on module installation, please visit the detailed CPAN module installation guide.