Simple flexible means of converting the output of php's serialize() into the equivalent perl memory structure, and vice versa.
use PHP::Serialization qw(serialize unserialize); my $encoded = serialize({ a => 1, b => 2}); my $hashref = unserialize($encoded);
Provides a simple, quick means of serializing perl memory structures (including object data!) into a format that \s-1PHP\s0 can deserialize() and access, and vice versa.
\s-1NOTE:\s0 Converts \s-1PHP\s0 arrays into Perl Arrays when the \s-1PHP\s0 array used exclusively numeric indexes, and into Perl Hashes then the \s-1PHP\s0 array did not.
Exportable functions.. Serializes the memory structure pointed to by $var, and returns a scalar value of encoded data.
If the optional $asString is true, $var will be encoded as string if it is double or float.
If the optional $sortHashes is true, all hashes will be sorted before serialization.
\s-1NOTE:\s0 Will recursively encode objects, hashes, arrays, etc.
\s-1SEE\s0 \s-1ALSO:\s0 ->encode()
Deserializes the encoded data in $encoded, and returns a value (be it a hashref, arrayref, scalar, etc) representing the data structure serialized in $encoded_string.
If the optional \s-1CLASS\s0 is specified, any objects are blessed into CLASS::$serialized_class. Otherwise, O bjects are blessed into PHP::Serialization::Object::$serialized_class. (which has no methods)
\s-1SEE\s0 \s-1ALSO:\s0 ->decode()
Functionality available if using the object interface..
Deserializes the encoded data in $encoded, and returns a value (be it a hashref, arrayref, scalar, etc) representing the data structure serialized in $encoded_string.
If the optional \s-1CLASS\s0 is specified, any objects are blessed into CLASS::$serialized_class. Otherwise, Objects are blessed into PHP::Serialization::Object::$serialized_class. (which has no methods)
\s-1SEE\s0 \s-1ALSO:\s0 unserialize() Serializes the memory structure pointed to by $reference, and returns a scalar value of encoded data.
If the optional $asString is true, $reference will be encoded as string if it is double or float.
If the optional $sortHashes is true, all hashes will be sorted before serialization.
\s-1NOTE:\s0 Will recursively encode objects, hashes, arrays, etc.
\s-1SEE\s0 \s-1ALSO:\s0 serialize()
Support diffrent object types
Copyright (c) 2003 Jesse Brown <[email protected]>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Various patches contributed by assorted authors on rt.cpan.org (as detailed in Changes file).
Currently maintained by Tomas Doran <[email protected]>.
Rewritten to solve all known bugs by BjA\*~Xrn-Olav Strand <[email protected]>