ADBRITE ads links
You are here: CodeIdol.com > Perl > Intermediate Perl > Manipulating Complex Data Structures
Intermediate Perl
| 6.1. Using the Debugger to View Complex Data
The Perl debugger can display complex data easily. For example, let's single-step through one version of the byte-counting program from Chapter 5:
my %total_bytes;
while (<&g...
|
|
| 6.2. Viewing Complex Data with Data::Dumper
Another way to visualize a complex data structure rapidly is to dump it. A particularly nice dumping package is included in the Perl core distribution, called Data::Dumper. Let's replace the las...
|
|
| 6.3. YAML
Data::Dumper is not the only game on the island, though. Brian Ingerson came up with Yet Another Markup Language (YAML) to provide a more readable (and more compact) dump. It works in the same way as Data::Dumper. We'll see m...
|
|
| 6.4. Storing Complex Data with Storable
We can take the output of Data::Dumper's Dumper routine, place it into a file, and then load the file to a different program. When we evaluate the code as Perl code, we end up with two package varia...
|
|
| 6.5. Using the map and grep Operators
As the data structures become more complex, it helps to have higher-level constructs deal with common tasks such as selection and
transformation. In this regard, Perl's grep and map operators are worth mast...
|
|
| 6.6. Applying a Bit of Indirection
Some problems that may appear very complex are actually simple once we've seen a solution or two. For example, suppose we want to find the items in a list that have odd digit sums but don't want the item...
|
|
| 6.7. Selecting and Altering Complex Data
We can use these operators on more complex data. Taking the provisions list from Chapter 5:
my %provisions = (
'The Skipper' => [qw(blue_shirt hat jacket preserver sunscreen)],
...
|
|
| 6.8. Exercises
You can find the answers to these exercises in "Answers for Chapter 6" in the Appendix.
6.8.1. Exercise 1 [20 min]
The program from Exercise 2 in Chapter 5 needs to read the entire datafile each time it runs. However, the Profes...
|
|
You are here: CodeIdol.com > Perl > Intermediate Perl > Manipulating Complex Data Structures
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|