|
发表于 2004-4-27 17:24:05
|
显示全部楼层
use CGI::Carp "fatalsToBrowser"; #显示错误信息到浏览器
use diagnostics; #显示详细的错误信息
#=================================================
用CGI.pm的时候是不用new 的
# CGI script that creates a fill-out form
# and echoes back its values. use CGI qw/:standard/;
print header,
start_html('A Simple Example'),
h1('A Simple Example'),
start_form,
"What's your name? ",textfield('name'),p,
"What's the combination?", p,
checkbox_group(-name=>'words',
-values=>['eenie','meenie','minie','moe'],
-defaults=>['eenie','minie']), p,
"What's your favorite color? ",
popup_menu(-name=>'color',
-values=>['red','green','blue','chartreuse']),p,
submit,
end_form,
hr; if (param()) {
print "Your name is",em(param('name')),p,
"The keywords are: ",em(join(", ",param('words'))),p,
"Your favorite color is ",em(param('color')),
hr;
}
只有一些需要,比如Cookie
use CGI qw/:standard/;
use CGI::Cookie; # Create new cookies and send them
$cookie1 = new CGI::Cookie(-name=>'ID',-value=>123456);
$cookie2 = new CGI::Cookie(-name=>'preferences',
-value=>{ font => Helvetica,
size => 12 }
);
print header(-cookie=>[$cookie1,$cookie2]); # fetch existing cookies
%cookies = fetch CGI::Cookie;
$id = $cookies{'ID'}->value; # create cookies returned from an external source
%cookies = parse CGI::Cookie($ENV{COOKIE}); |
|