# phpman > perldoc > Data::Serializer::Raw

## NAME
    [Data::Serializer::Raw](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer%3A%3ARaw/markdown) - Provides unified raw interface to perl serializers

## SYNOPSIS
      use [Data::Serializer::Raw](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer%3A%3ARaw/markdown);

      $obj = [Data::Serializer::Raw](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer%3A%3ARaw/markdown)->new();

      $obj = [Data::Serializer::Raw](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer%3A%3ARaw/markdown)->new(serializer => 'Storable');

      $serialized = $obj->serialize({a => [1,2,3],b => 5});
      $deserialized = $obj->deserialize($serialized);

      print "$deserialized->{b}\n";

## DESCRIPTION
    Provides a unified interface to the various serializing modules currently available.

    This is a straight pass through to the underlying serializer, nothing else is done. (no
    encoding, encryption, compression, etc)

## EXAMPLES
    Please see [Data::Serializer](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer/markdown)::[Cookbook(3)](https://www.chedong.com/phpMan.php/man/Cookbook/3/markdown)

## METHODS
    new - constructor
          $obj = [Data::Serializer::Raw](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer%3A%3ARaw/markdown)->new();


          $obj = [Data::Serializer::Raw](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer%3A%3ARaw/markdown)->new(
                                 serializer => '[Data::Dumper](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ADumper/markdown)',
                                   options  => {},
                                );

        new is the constructor object for [Data::Serializer::Raw](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer%3A%3ARaw/markdown) objects.

        *   The default *serializer* is "[Data::Dumper](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ADumper/markdown)"

        *   The default *options* is "{}" (pass nothing on to serializer)

    serialize - serialize reference
          $serialized = $obj->serialize({a => [1,2,3],b => 5});

        This is a straight pass through to the underlying serializer, nothing else is done. (no
        encoding, encryption, compression, etc)

    deserialize - deserialize reference
          $deserialized = $obj->deserialize($serialized);

        This is a straight pass through to the underlying serializer, nothing else is done. (no
        encoding, encryption, compression, etc)

    serializer - change the serializer
        Currently supports the following serializers:

        [Bencode(3)](https://www.chedong.com/phpMan.php/man/Bencode/3/markdown)
        Convert::[Bencode(3)](https://www.chedong.com/phpMan.php/man/Bencode/3/markdown)
        Convert::[Bencode_XS(3)](https://www.chedong.com/phpMan.php/man/BencodeXS/3/markdown)
        Config::[General(3)](https://www.chedong.com/phpMan.php/man/General/3/markdown)
        Data::[Denter(3)](https://www.chedong.com/phpMan.php/man/Denter/3/markdown)
        Data::[Dumper(3)](https://www.chedong.com/phpMan.php/man/Dumper/3/markdown)
        Data::[Taxi(3)](https://www.chedong.com/phpMan.php/man/Taxi/3/markdown)
        [FreezeThaw(3)](https://www.chedong.com/phpMan.php/man/FreezeThaw/3/markdown)
        [JSON(3)](https://www.chedong.com/phpMan.php/man/JSON/3/markdown)
        JSON::[Syck(3)](https://www.chedong.com/phpMan.php/man/Syck/3/markdown)
        PHP::[Serialization(3)](https://www.chedong.com/phpMan.php/man/Serialization/3/markdown)
        [Storable(3)](https://www.chedong.com/phpMan.php/man/Storable/3/markdown)
        XML::[Dumper(3)](https://www.chedong.com/phpMan.php/man/Dumper/3/markdown)
        XML::[Simple(3)](https://www.chedong.com/phpMan.php/man/Simple/3/markdown)
        [YAML(3)](https://www.chedong.com/phpMan.php/man/YAML/3/markdown)
        YAML::[Syck(3)](https://www.chedong.com/phpMan.php/man/Syck/3/markdown)

        Default is to use [Data::Dumper](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ADumper/markdown).

        Each serializer has its own caveat's about usage especially when dealing with cyclical data
        structures or CODE references. Please see the appropriate documentation in those modules for
        further information.

    options - pass options through to underlying serializer
        Currently is only supported by Config::[General(3)](https://www.chedong.com/phpMan.php/man/General/3/markdown), and XML::[Dumper(3)](https://www.chedong.com/phpMan.php/man/Dumper/3/markdown).

          my $obj = [Data::Serializer::Raw](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer%3A%3ARaw/markdown)->new(serializer => '[Config::General](https://www.chedong.com/phpMan.php/perldoc/Config%3A%3AGeneral/markdown)',
                                          options    => {
                                                     -LowerCaseNames       => 1,
                                                     -UseApacheInclude     => 1,
                                                     -MergeDuplicateBlocks => 1,
                                                     -AutoTrue             => 1,
                                                     -InterPolateVars      => 1
                                                        },
                                                      ) or die "$!\n";

          or

          my $obj = [Data::Serializer::Raw](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer%3A%3ARaw/markdown)->new(serializer => '[XML::Dumper](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ADumper/markdown)',
                                          options    => { dtd => 1, }
                                          ) or die "$!\n";

    store - serialize data and write it to a file (or file handle)
          $obj->store({a => [1,2,3],b => 5},$file, [$mode, $perm]);

          or

          $obj->store({a => [1,2,3],b => 5},$fh);

        Serializes the reference specified using the serialize method and writes it out to the
        specified file or filehandle.

        If a file path is specified you may specify an optional mode and permission as the next two
        arguments. See [IO::File](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3AFile/markdown) for examples.

        Trips an exception if it is unable to write to the specified file.

    retrieve - read data from file (or file handle) and return it after deserialization
          my $ref = $obj->retrieve($file);

          or

          my $ref = $obj->retrieve($fh);

        Reads first line of supplied file or filehandle and returns it deserialized.

## AUTHOR
    Neil Neely <<neil@neely.cx>>.

    <http://neil-neely.blogspot.com/>

## BUGS
    Please report all bugs here:

    <http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer>

## COPYRIGHT AND LICENSE
    Copyright (c) 2011 Neil Neely. All rights reserved.

    This library is free software; you can redistribute it and/or modify it under the same terms as
    Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may
    have available.

    See <http://www.perl.com/language/misc/Artistic.html>

## ACKNOWLEDGEMENTS
    Peter Makholm took the time to profile Data::[Serializer(3)](https://www.chedong.com/phpMan.php/man/Serializer/3/markdown) and pointed out the value of having a
    very lean implementation that minimized overhead and just used the raw underlying serializers.

## SEE ALSO
### perl

