Make HTML Concise

Tag Functions are Distributive

print li('hi','how','are','you')
<LI>hi how are you</LI>

@items=('hi','how','are','you'); print li(\@items)
<LI>hi</LI>
<LI>how</LI>
<LI>are</LI>
<LI>you</LI>

print li(['hi','how','are','you'])
<LI>hi</LI>
<LI>how</LI>
<LI>are</LI>
<LI>you</LI>

Add HTML Attributes Using Hash References

%opts=(-type=>'square'); @items=('hi','how','are','you'); print li(\%opts,\@items)
<LI TYPE="square">hi</LI>
<LI TYPE="square">how</LI>
<LI TYPE="square">are</LI>
<LI TYPE="square">you</LI>

print li({-type=>'square'},['hi','how','are','you'])
<LI TYPE="square">hi</LI>
<LI TYPE="square">how</LI>
<LI TYPE="square">are</LI>
<LI TYPE="square">you</LI>

Script 2: vegetables2.pl


 #!/usr/bin/perl
 # Script: vegetables2.pl

 use CGI ':standard';

 print header,
    start_html('Vegetables'),
    h1('Eat Your Vegetables'),
    ol(
       li(['peas',
	   'broccoli',
	   'cabbage',
	   'peppers' .
           ul(['red','yellow','green']),
           'kolrabi',
           'radishes'])
       ),
    hr,
    end_html;

What it Looks Like

http://your.host/cgi-bin/vegetables2.pl
<< Previous Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Fri Oct 22 14:42:28 EDT 1999