CGI.pm

CGI.pm
원저자Lincoln Stein
개발자리 존슨
안정화 버전
4.21 / 2015-06-22
플랫폼
종류CGI펄 모듈
웹사이트metacpan.org/release/CGI

CGI.pm공용 게이트웨이 인터페이스(CGI) 애플리케이션의 프로그래밍을 위해 널리 사용되는 대형 펄 모듈로서, 사용자 입력을 수신하고 처리하기 위한 일정한 API를 제공한다. HTML 또는 XHTML 출력을 생성하기 위한 기능도 있으나 이것들은 현재 유지보수되지 않고 있으며 배제될 예정이다.[1] CGI.pm은 코어 펄 모듈이었으나 펄 v5.22를 기준으로 제거된 상태이다.[2] 이 모듈은 링컨 스타인에 의해 작성되었으며 현재는 리 존슨에 의해 유지보수되고 있다.

예제

다음은 CGI.pm을 사용하여 펄로 작성된 단순한 CGI 페이지이다. (객체 지향 스타일):

#!/usr/bin/env perl

use strict;
use warnings;

use CGI;

my $cgi = CGI->new;

print $cgi->header('text/html');

print << "EndOfHTML";
<!DOCTYPE html>
<html>
    <head>
        <title>A Simple CGI Page</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
        <h1>A Simple CGI Page</h1>
        <form method="post" enctype="multipart/form-data">
            Name: <input type="text" name="name"  /><br />
            Age: <input type="text" name="age"  /><p>
            <input type="submit" name="Submit!" value="Submit!" />
        </form>
        <hr />
EndOfHTML

if ( my $name = $cgi->param('name') ) {
    print "Your name is $name.<br />";
}

if ( my $age = $cgi->param('age') ) {
    print "You are $age years old.";
}

print '</body></html>';

같이 보기

각주

외부 링크

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.