Skip to Main Content
Perl in a Nutshell
book

Perl in a Nutshell

by Nathan Patwardhan, Ellen Siever, Stephen Spainhour
December 1998
Beginner to intermediate content levelBeginner to intermediate
674 pages
40h 41m
English
O'Reilly Media, Inc.
Content preview from Perl in a Nutshell

Data::Dumper

Converts Perl data structures into strings that can be printed or used with eval to reconstruct the original structures. Takes a list of scalars or reference variables and writes out their contents in Perl syntax. Several interfaces to Data::Dumper are provided:

  • Simple procedural interface:

    print Dumper($foo, $bar);

  • Extended usage with names:

    print Data::Dumper->Dump([$foo, $bar], [qw(foo *ary)]);

  • Object-oriented interface:

    $d = Data::Dumper->new([$foo, $bar], [qw(foo *ary)]);
       ...
    print $d->Dump;

By default, references are identified as $VAR n, where n is a numeric suffix. References to substructures within $VAR n are labeled using arrow notation. In the extended usage form, references can be given user-specified names. See the Data::Dumper manpage for examples of the module’s use.

Several configuration variables can be used to control the output generated using the procedural interface. These variables control the default state of the object created by the new method. Each variable has a corresponding method that can be used later to query or modify the object. In the following list, each variable is followed by the corresponding method:

$Data::Dumper::Bless , $obj->Bless([ newval ])

Can be set to a string that specifies an alternative to the bless builtin operator used to create objects. A function with the specified name should exist and should accept the same arguments as the builtin. Default is bless.

$Data::Dumper::Deepcopy , $obj->Deepcopy([ newval ])

If set ...

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

Perl One-Liners

Perl One-Liners

Peteris Krumins
Beginning Perl

Beginning Perl

Curtis Ovid Poe
Mastering Perl

Mastering Perl

brian d foy
Perl Best Practices

Perl Best Practices

Damian Conway

Publisher Resources

ISBN: 1565922867Catalog PageErrata