);
print end_html;
四 url
$full_url = url(); # http://your.host.com/path/to/script.cgi
$full_url = url(-full=>1); # http://your.host.com/path/to/script.cgi
$relative_url = url(-relative=>1); #script.cgi
$absolute_url = url(-absolute=>1); #path/to/script.cgi
$url_with_path = url(-path_info=>1);
$url_with_path_and_query = url(-path_info=>1,-query=>1);
$netloc = url(-base => 1); #http://your.host.com
五 CGI.pm中的html元素方法的特殊用法
如果元素的第二个参数为list类型,则会被分解,例如:
print ul(
li({-type=>'disc'},['Sneezy','Doc','Sleepy','Happy'])
);
相当于:
<ul>
<li type="disc">Sneezy</li>
<li type="disc">Doc</li>
<li type="disc">Sleepy</li>
<li type="disc">Happy</li>
</ul>
例如table可以写为:
print table({-border=>undef},
caption('When Should You Eat Your Vegetables?'),
Tr({-align=>'CENTER',-valign=>'TOP'},
[
th(['Vegetable', 'Breakfast','Lunch','Dinner']),
td(['Tomatoes' , 'no', 'yes', 'yes']),
td(['Broccoli' , 'no', 'no', 'yes']),
td(['Onions' , 'yes','yes', 'yes'])
]
)
);
六 CGI.pm中非标准的html元素方法
print comment('here is my comment'); #generates an HTML comment (<!-- comment -->)
因为与perl方法冲突,所以大写的:
Select









