Perlを使う1 〜 インストール

まずは、環境構築。
今回は、PHPも使用することになったので、XAMPPを導入する。

XAMPP Apache + MySQL + PHP + Perl」のページからダウンロードしてインストールする。クリックしていくだけ。

インストールしたら起動する。

右のほうにある、shellをクリックしてプロンプトを起動する。

perlバージョン確認

# perl -v

This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x86-multi-t
hread

Copyright 1987-2012, Larry Wall

すでにperl6がリリースされているが、XAMPP(今回は、Windows 向け XAMPP v1.8.3 (PHP 5.5.11))では、perl5だった。。。

ただ、今回の目的は初めてのperlのさわりの勉強なので、perlのverはきにしないでおく。

apacheを起動する
起動後、http://localhost/xampp/splash.phpにアクセスすると、XAMPPのページが表示される。

CGIperlを動かしてみる
デフォルトで、xamppのインストールフォルダ(今回はC:\xampp)のcgi-binフォルダにCGIのサンプルプログラムが格納されているため、それを動かしてみる。

ここでは、perltest.cgiというサンプルを動かす。
内容は下記。

#!"C:\xampp\perl\bin\perl.exe"

print "Content-type: text/html\n\n";
print '<html>';
print '<head>';
print '<meta name="author" content="Kay Vogelgesang">';
print '<link href="/xampp/xampp.css" rel="stylesheet" type="text/css">';
print '</head>';
print "<body>&nbsp;<p><h1>GCI with MiniPerl</h1>";
print  "CGI with MiniPerl is ready ...</body></html>";

http://localhost/cgi-bin/perltest.cgiと打ち込むと画面が表示される。