Data::Dumper

Oct 16, 2007

Data::Dumper is one of the most useful Perl modules when developing code, providing quick and easy access to the contents of data structures. Are you unsure whether you’re setting the values of a hash correctly? Don’t understand how someone has organized an object that you’re ‘use'ing? Data::Dumper to the rescue.

Note that I passed Dumper() a reference to the 'foo’ hash by using a backslash, which is what you will want most of the time with anything other than a scalar. Passing a reference causes Dumper() to print the entire variable’s contents in the same scope. If you pass 'foo’ directly, instead of its reference, you end up with this: