0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Perl xampp でperl/CGIを動かそう。

Posted at

xamppについてきているんだから、動かせる知識は持っていて損はないでしょうね。
cgi が、何かは。。。
https://www.bing.com/search?q=cgi&form=ANSPH1&refig=4d2dcc4ba4f04ae6b34c905121694567&pc=W011&showconv=1
BingAI やわ。無料で聞けるで。読み上げモードと入れてね。説明してくれたやろ?

テキスト形式だから、textで書いておけば良いのだが、utf8言うのを覚えといて、それで、話をするから。
まず、html でtext型式で話すと知らせるんや。他にもzipとかイメージとかあるから、テキストと。
次に html の何や言うの。バージョン違うと困るやろ。昔の話は小学生の時とつけてもらわんと。
次になくても良いが、英語圏で無いから、お国は「日本」と英語で短く。
その次は無くても良いが、fileとして、初めの(head)産まれる時は頭から、一応、そういう決まりや。
head の中での情報
meta charset="UTF-8" 日本人の教育受けますよって標準語として、安土桃山やないと。
title 上のタブでこのページはQiitaやと書いているように。真似されんように、もう少し前にiconを入れられるが、持っていないやろ? *.ico 言うファイル。
書いていないのもあるが、この中で指示、定義をしてひとまずhead終わる。
BODY 足とか手とかいろいろ書くとこ。
ここに、言いたいことをタグと言う物を使って書いておく。
全体BODYの閉じをして
htmlの終わりを知らせて、私の手はかかりませんよって終わる。
例として

#!C:/xampp/Perl/bin/perl

print "Content-type:text/html\n\n";
print <<EOF ;
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<BODY BGCOLOR="#ffffff">
<h1>xampp perl test</h1>
</BODY>
</html>
EOF
exit;

見慣れんのが、先頭にあるな。って、仕事の依頼先で、一応「依頼(#!)」と書いてあって、最初に一回しか受けんぞ、宛先はC:/xampp/Perl/bin/perlやと。
これだと、htmlと変わらんやろ、もっとできるやつや、って、その2。

#!C:/xampp/Perl/bin/perl

$point_err = 'bol1_1';
$point_return = 'bol2_0';
$settig_msgA = 'NO Settig.';
$settig_msgB = 'NO Settig.';
$error_detail = 'No Error.';
sub my_error(error_detail){
	#callされた時点での変数内容に従う。
	if($point_err eq 'bol1_1'){
        print "Content-type:text/html\n\n";
        print "<!DOCTYPE html><html lang=\"ja\"><head><meta charset=\"UTF-8\"><title>Error</title></head><body>";
	}
	print "<h1>エラー発生(An error has occurred.)</h1><h2>detail $_[0]</h2><div style=\"background-color: #000066;color: #cccccc;font-size: 12px;margin: 3px;padding: 3px;\">$settig_msgA</div><div style=\"background-color: #006600;color: #cccccc;font-size: 12px;margin: 3px;padding: 3px;\">$settig_msgB</div><br>";
	
	if($point_return eq  'bol2_1'){
		return;
	}
	print"</body></html>\n";
	exit;
}
# &my_error('test error.');
$settig_msgB .= 'kokowo tsuuka.';
$point_err = 'bol1_0';# ヘッダー作成領域を過ぎたので、チェンジ。
print "Content-type:text/html\n\n";
print <<MY_EOF ;
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<BODY BGCOLOR="#ffffff">
<h1>xampp perl test</h1>
MY_EOF
$point_return = 'bol2_1';# 表示した後戻ってもらう事にここから戻せば終わる。

$puroburem = "i't no";
$settig_msgA  = "problem $puroburem problem".'.'; $settig_msgB .= $settig_msgA;
&my_error('test error.');

print <<MY_EOF ;
テスト終了
</BODY>
</html>
MY_EOF
exit;

やってみた結果を、お楽しみに。書いていてイメージ出来れば、釈迦に説法だが、釈迦はそれも、考えた、結果が楽しみと、聞くだけやと、思うが。
次回に続く。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?