Skip to Content
Perl Debugged
book

Perl Debugged

by Peter Scott, Ed Wright
March 2001
Intermediate to advanced
288 pages
4h 56m
English
Addison-Wesley Professional
Content preview from Perl Debugged

5.1. Dumping Your Data

That is all well and good for scalars and arrays, but it won't even handle hashes, let alone complex lists of lists. A good way to deal with those is to use the Dumper function in the Data::Dumper module which will let you print out, nicely formatted, anything you give it, no matter how complex:

use Data::Dumper;
# set %state from some database or flat file
warn Dumper(\%state);

which produces

$VAR1 = {
          'WI' => {
                    'BIRD'         => 'Robin',
                    'NAME'         => 'Wisconsin',
                    'LARGEST_CITY' => 'Milwaukee',
                    'CAPITAL'      => 'Madison',
                    'FLOWER'       => 'Wood Violet'
                  },
          'MS' => {
                    'BIRD'         => 'Mockingbird',
                    'NAME'         => 'Mississippi',
                    'LARGEST_CITY' => 'Jackson',
                    'CAPITAL'      => 'Jackson',
                    'FLOWER'       => 'Magnolia'
                  },
[...]

Note that we passed a reference to the ...

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 Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe
Pro Perl

Pro Perl

Peter Wainwright
Intermediate Perl

Intermediate Perl

Randal L. Schwartz, brian d foy, Tom Phoenix
Perl Testing: A Developer's Notebook

Perl Testing: A Developer's Notebook

Ian Langworth, Chromatic

Publisher Resources

ISBN: 0201700549Purchase book