Chapter 6. Generating HTML
Continuing the example begun in the previous chapter, it’s time
for us to modify our script, make_exhibit.plx
, to
output the
HTML pages for the SprocketExpo 2000
exhibitor’s directory.
The Modified make_exhibit.plx Script
The final version of make_exhibit.plx
is given in
Example 6-1. It features a fair number of changes
from the previous version, but don’t worry; we’ll be
going through those changes one by one, explaining them all.
Example 6-1. The final version of make_exhibit.plx
#!/usr/bin/perl -w # make_exhibit.plx # this script reads a pair of data files, extracts information # relating to a group of tradeshow exhibitors, and writes # out a browseable web-based directory of those exhibitors use strict; # configuration section: my $exhibit_file = './exhibit.txt'; my $category_file = './category.txt'; my $base_path = '/w1/s/sprocketexpo/exhibit'; my $base_url = '/exhibit'; my $show_name = 'SprocketExpo 2000'; # scriptwide variables: my %listing; # key: company name ($co_name). # value: HTML-ized listing for this company. my %letter_count; # key: lowercase letter. # value: count of exhibitors starting with # that letter (for creating entries # in %listing_path). my %listing_path; # key: company name ($co_name). # value: path (relative to $base_path) of # this company's HTML listing page. # takes the form 'listings/a/a1.html'. my %index_line; # key: company name ($co_name). # value: HTML-ized <LI> link to listing page. my %companies_by_category; # key: ...
Get Perl for Web Site Management now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.