初心者だけどPerlが大好き

コードが世界を変える!

川合孝典さん翻訳のCGI.pm

CGI.pm というモジュールは コアモジュールです。
ppm でインストールする必要はありません。
いまや Perl5.8 を書くときには
必ず use CGI; と書いて使います。

本家のサイトは こちら。
http://search.cpan.org/~lds/CGI.pm-3.49/lib/CGI.pm

川合孝典さん翻訳
http://perldoc.jp/docs/modules/CGI.pm-2.89/CGI.pod
オブジェクト指向と関数表記が混在してバラバラに説明されているので
オブジェクト指向でまとめてみました

xamppのhtdocsに 適当な名前で たとえばmdcgi.cgi とかで
http://localhost/CGIの名前.cgi として呼び出してね

#!D:/xampp/perl/bin/perl -w  #私が単にDドライブに入れているため
use CGI;            # CGIルーチンのロード
use utf8;                 
$q = new CGI;              # 新しいCGIオブジェクトの作成
print $q->header;
print $q->start_html(-title=>'Secrets of the Pyramids',
                -author=>'fred@capricorn.org',
                -base=>'true',
                -target=>'_blank',
                -meta=>{'keywords'=>'pharaoh secret mummy',
                    'copyright'=>'copyright 1996 King Tut'},
                -style=>{'src'=>'/styles/style1.css'},
                -BGCOLOR=>'blue');
print  $q->h1('hello world');  # レベル1のヘッダ

print $q->blockquote(
             "Many years ago on the island of",
             $q->a({href=>"http://crete.org/"},"Crete"),
             "there lived a Minotaur named",
             $q->strong("Fred."),
            ),
print$q->hr;
print $q->end_html;  # HTMLの終わり