"HTML 생성 기능"을 피하는 것이 효과적이지 않습니다.
"안녕하세요 펄"perl이 "HTML 생성 기능"을 피함
그러나 perldoc을 조언을 : 예상대로 내가
#!/usr/bin/perl
print "Content-type:text/html\r\n\r\n";
print '<html>';
print '<head>';
print '<title>Hello Perl</title>';
print '</head>';
print '<body>';
print '<h2>Hello perl</h2>';
print '</body>';
print '</html>';
내 브라우저 인쇄를 내 로컬 호스트에 펄 스크립트를 시작하면
"HTML 생성 기능은 더 이상 사용할 수없는 ".
그래서 객체 지향 cgitutorial-script (perl, v5.10.0)를 시도했습니다.
#!/usr/bin/perl -w
use CGI;
$q = new CGI;
print $q->header,
$q->start_html('hello world'),
$q->h1('hello world'),
$q->end_html;
브라우저는 내가
$perl mycgi.pl
와 터미널에 위의 스크립트를로드하는 경우
"내부 서버 오류"
그것이 예상되는 결과를 보여줍니다
Content-Type: text/html; charset=ISO-8859-1
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>hello world</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>hello world</h1>
</body>
</html>
무엇이 실종 됐습니까? 귀하의 코멘트에서
거기에 여분의't'가 무엇입니까? – mwp
[_HTML 생성 함수는 더 이상 사용하지 않아야합니다] (http://search.cpan.org/~leejo/CGI-4.37/lib/CGI.pod#HTML_Generation_functions_should_no_longer_be_used)는 CGI 함수를 사용하지 마십시오. '$ q-> start_html (...)'과 같은 것입니다. 이들은 HTML을 생성하는 함수입니다. ;-) CGI의 [대안] (http://search.cpan.org/~leejo/CGI-Alternatives-0.15/lib/CGI/Alternatives.pm)에서 [Mojolicious] (http : //mojolicious.org/) 또는 [Dancer2] (http://perldancer.org/) 또는 [Catalyst] (http://www.catalystframework.org/). 일단 그들과 함께 시작하면, 당신은 그것을 좋아할 것입니다. 약속 했어. – PerlDuck
첫 번째 스크립트는 HTML을 직접 작성합니다. 그것은 HTML 생성 함수를 사용하는 것이 아닙니다. 두 번째 것은 그들을 사용합니다. 나는 첫 번째 버전을 선호 하겠지만 여전히 추악합니다. SawyerX의 [lightning talk] (https://www.youtube.com/watch?v=jKOqtRMT85s)를 시청하시기 바랍니다. – simbabque