Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

11. References and Records > 11.11. Printing Data Structures

11.11. Printing Data Structures

Problem

You want to print out a data structure.

Solution

If the output’s legibility and layout are important, write your own custom printing routine.

If you are in the Perl debugger, use the x command:

DB<1> $reference = [ { "foo" => "bar" }, 3, sub { print "hello, world\n" } ];
DB<2> x $reference
  
               0  ARRAY(0x1d033c)
               0  HASH(0x7b390)
               foo' = 'bar
               1  3
               2  CODE(0x21e3e4)
               -> &main::_ _ANON_ _[(eval 15)[/usr/local/...perl5db.pl:17]:2]
               in (eval 15)[/usr/local/.../perl5db.pl:17]:2-2

From within your own programs, use the Dumper function from the standard module Data::Dumper:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint