Homework

2002-07-11
Understand coderefs! (Subroutine references.) Re-read chapter 4 of Programming Perl, 2nd-edition or chapter 8 of Programming Perl, 3rd-edition.
Using make_treewalker() and walk_tree() as a template, create an infinite list of integers, such that:
for (my $l = make_infinite_list(0); ; $l = $l->[1]->()) {
  print $l->[0] . ", ";
}
Will print '0, 1, 2, 3, 4, ...' off to infinity. Can you improve on the interface?
Download and examine the module ExtUtils-MakeMaker. See how it is packaged and what files are created when it is built.
2002-07-09
Understand each line and construct in the guestbook demo program. If anything is not understood, send an email to me for clarification.
Look up the module Data::Dumper. Use it to test nested data structures and references.
In class we wrote a function that takes a Perl representation of HTML and converted it back to HTML. Let us call this function perl_to_html(). However, this function has at least one bug: HTML elements such as code, img, and meta cannot be closed with </tag>. Fix this.
Write the reciprical function to perl_to_html(): write a function html_to_perl() that consumes a string that is valid HTML and returns our Perl representation of the HTML. Feed the output of html_to_perl() into perl_to_html() and see how the string input and output match.
For a refresher: given <p class="messy">Foo <strong>bar</strong><p> , we get in Perl [ "p", { class => "messy" }, "Foo ", [ "strong", "bar" ] ] .
Read up on code references, closures, infinite lists, lazy evaluation, dispatch tables, and function prototypes.

Retrospective,

This makes me want to write Perl again.


Advanced Perl Programming

Mike Burns <mike@mike-burns.com>