Data::Dumper is a standard Perl Module that you may find
extremely useful in debugging your code for Homework 4. This module
imports a function that will print a human-readable list of all
information contained within a variable. This is most beneficial for
dealing with multi-dimensional data structures.The page for Data::Dumper is at http://www.perldoc.com/perl5.6/lib/Data/Dumper.html. Here is a quick overview:
First, include the module by putting this line near the top of your
code:
use Data::Dumper;
Then, call the Dumper() function and pass in a reference to your data
structure. If, for example, you have a hash called %students that
holds all of your information, you would type the line:
print Dumper(\%students);
This will print out all levels of data stored in your structure. For
example, let's say our %students structure is a hash of arrays. The
key of the hash is the students' last name, and the array is a list of
integers representing homework grades. If I made the call above, it
would print something like the following:
$VAR1 = {
'Lalli' => [
100,
95,
86
],
'Smith' => [
87,
92,
100,
84
],
'Jones' => [
32,
81
]
};
This is very useful for figuring out what your data structure
currently holds, and determining exactly what syntax you need to be
using to get at the pieces of your structure you're looking for. I
would encourage everyone to add another option 'd' for Dumper that
just prints out whatever is in the data structure (don't print this
option on the main menu, but use it in your own debugging process).