FreezeThaw is a Perl module for converting Perl structures to strings and back.
SYNOPSIS
use FreezeThaw qw(freeze thaw cmpStr safeFreeze cmpStrHard);
$string = freeze $data1, $data2, $data3;
...
($olddata1, $olddata2, $olddata3) = thaw $string;
if (cmpStr($olddata2,$data2) == 0) {print "OK!"}
Converts data to/from stringified form, appropriate for saving-to/reading-from permanent storage.
Deals with objects, circular lists, repeated appearence of the same refence. Does not deal with overloaded stringify operator yet.
EXPORT
Exportable
freeze thaw cmpStr cmpStrHard safeFreeze.
User API
cmpStr
analogue of cmp for data. Takes two arguments and compares them as separate entities.
cmpStrHard
analogue of cmp for data. Takes two arguments and compares them considered as a group.
freeze
returns a string that encupsulates its arguments (considered as a group). thawing this string leads to a fatal error if arguments to freeze contained references to GLOBs and CODEs.
safeFreeze
returns a string that encupsulates its arguments (considered as a group). The result is thawable in the same process. thawing the result in a different process should result in a fatal error if arguments to safeFreeze contained references to GLOBs and CODEs.
thaw
takes one string argument and returns an array. The elements of the array are "equivalent" to arguments of the freeze command that created the string. Can result in a fatal error (see above).
Limitations:
A lot of objects are blessed in some obscure packages by XSUB typemaps. It is not clear how to (automatically) prevent the UNIVERSAL methods to be called for objects in these packages.
The objects which can survive freeze()/thaw() cycle must also survive a change of a "member" to an equal member. Say, after
$a = [a => 3];
$a->{b} = $a->{a};
$a satisfies
$a->{b} == $a->{a}
This property will be broken by freeze()/thaw(), but it is also broken by
$a->{a} = delete $a->{a};
Product's homepage
Requirements:
· Perl