use Data::Dumper; print Dumper($store);
When used on the example from
Class::Struct
, this prints:
$VAR1 = bless( { 'Shoppe::owner' => 'Abdul Alhazred', 'Shoppe::stock' => { 'charms' => 3, 'books' => 208, 'potions' => 'none' }, 'Shoppe::boss' => bless( { 'Manager::name' => 'Prof L. P. Haitch', 'Manager::salary' => 'madness', 'Manager::started' => 'Sat Apr 1 16:18:13 2000' }, 'Manager' ), 'Shoppe::addrs' => [ 'Miskatonic University', 'Innsmouth, Mass.' ] }, 'Shoppe' );
The Data::Dumper
module's
Dumper
function takes a list of scalars (including
references, which can even refer to objects) and returns a printable
or eval
able string that accurately reproduces an
faithful copy of the original. You could use this to write out a saved
version of a data structure to a regular disk file or into a DBM file,
or to pass it to another process over a pipe or socket connection.
This module can be used with MLDBM
from CPAN and
DB_File
to implement a DBM file that can
transparently store complex data values, not just flat strings. Other
stringification (or serialization, or
marshalling) modules include
Storable
and FreezeThaw
, both
available from CPAN.