ロリコンの法則

http://jjx.xxperlxx.org/cgi-bin/lolicom.cgi
衝動的にこんなものを作成。 うーん。 むなしい。 んでもCGIMini::Templateは便利だぜ!と自画自賛



コードです。
テンプレは別ファイルでも良いんですが面倒なので__DATA__にしてみた。
それにしても普通にプログラムよりテンプレの方が長い・・・。

#! /usr/bin/perl

use strict;
use CGIMini;
use CGIMini::FormData;
use CGIMini::Template;

use constant Pi => 3.141592;

my $cgi = CGIMini->new;
my $q   = CGIMini::FormData->new;
my $tmpl= CGIMini::Template->new( template => \*DATA );

$tmpl->param( ENV => { %ENV } );
$tmpl->param( age => $q->param('age') );
$tmpl->param( result => Pi * sqrt($q->param('age'))) if($q->param('age') >= 0);

print $cgi->header, $tmpl->output;

__DATA__
<?xml version="1.0" encoding="Shift_JIS"?>
<!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" xml:lang="ja" lang="ja">
<head>
        <meta http-equiv="content-type" content="text/html" />
        <link rel="stylesheet" type="text/css" href="/main.css" />
        <script src="/common.js" type="text/javascript"></script>
        <title>ロリコンの法則</title>
</head>
<body>
<h1>ロリコンの法則 pi * √age</h1>
<div class="topmenu">
    <a href="http://xxperlxx.org/">[xxperlxx.org server]</a>
    <a href="/">[TopPage]</a>
    <a href="mailto:admin@xxperlxx.org">[Mail]</a>
</div>
<hr />
<tmpl:if name="result">
    <span style="font-size: 30px; font-weight: bold; color: red;">%%result%%</span>才以下の女の子が好きならあなたは<strong>ロリコン</strong>です。
</tmpl:if>

<form action="%%ENV::REQUEST_URI%%">
    あなたの年齢:<input type="text" name="age" value="%%age%%" size="2" /><input type="submit" value="測定" />
</form>

<img src="lolicom_img.gif" alt="pi*√age" />
<hr />
<div class="banners">
    <a href="http://www.apache.jp/" target="_blank"><img src="/images/apache_pb.gif" alt="Apache" /></a>
    <a href="http://www.perl.com/" target="_blank"><img src="/images/rectangle_power_perl.gif" alt="Perl" /></a>
</div>
</body>
</html>