Skip to Main Content
Programming Perl, 3rd Edition
book

Programming Perl, 3rd Edition

by Larry Wall, Tom Christiansen, Jon Orwant
July 2000
Intermediate to advanced content levelIntermediate to advanced
1104 pages
35h 1m
English
O'Reilly Media, Inc.
Content preview from Programming Perl, 3rd Edition

Data::Dumper

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 evalable 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.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl, 2nd Edition

Mastering Perl, 2nd Edition

brian d foy
Programming the Perl DBI

Programming the Perl DBI

Tim Bunce, Alligator Descartes
Perl in a Nutshell, 2nd Edition

Perl in a Nutshell, 2nd Edition

Nathan Patwardhan, Ellen Siever, Stephen Spainhour

Publisher Resources

ISBN: 0596000278Supplemental ContentErrata