1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
#!/usr/bin/perl
# 初期設定
# require Jcode;
# *Jgetcode = &Jcode::getcode;
# *Jconvert = &Jcode::convert;
require "../../../cgi-bin/jcode.pl";
*Jgetcode = &jcode::getcode;
*Jconvert = sub { &jcode::to($_[1], $_[0], $_[2]); };
@G_styles = ("../../ipp.css","../test.css");
$G_title = "テスト15";
$G_myCode = &Jgetcode("漢字");
$G_Code = "jis";
$G_Charset = "ISO-2022-JP";
$G_scrName = $ENV{'SCRIPT_NAME'};
if($G_scrName =~ /ts[0-9]{4}/){
$G_scrName = $&;
$G_linkFile = "../$G_scrName.htm";
}
# 固有設定
$G_inFile = "ts0014.cgi";
# $G_outCode = "utf8";
$G_outCode = "euc";
$G_outFile = $G_inFile;
# $G_outFile =~ s/.cgi/_u.txt/;
$G_outFile =~ s/.cgi/_e.txt/;
{
&printHeader;
print "<div class=test>n";
&fileOUT ($G_outFile, &fileIN($G_inFile));
&Jprint ("<a href="$G_outFile">出力が完了しました。</a>n");
print "</div>n";
&printFooter;
exit;
}
sub fileOUT{
local($outFile)= shift(@_);
local(@outFileLines) = @_;
&Jprint ("出力ファイル名 : ");
print $outFile;
print "<br>n";
# &printSource(@_);
open (OUT, "> $outFile");
foreach (@outFileLines){ print OUT &Jconvert($_, $G_outCode, &Jgetcode($_)); }
close (OUT);
# &Jprint ("以上の内容で出力しました。");
}
sub fileIN{
local(@inFileLines);
local($inFile) = $_[0];
&Jprint ("入力ファイル名 : ");
print $inFile;
print "<br>n";
open (IN, $inFile);
@inFileLines = <IN>;
close (IN);
return @inFileLines;
}
sub printSource{
local(@lines)= @_;
local($line);
print "<ol>n";
foreach $line (@lines){
$line =~ s/&/&amp;/g;
$line =~ s/"/&quot;/g;
$line =~ s/</&lt;/g;
$line =~ s/>/&gt;/g;
$line =~ s/ /&nbsp;/g;
print &JconvPrint("<li><code>$line</code>");
}
print "</ol>n";
}
sub printHeader{
if($G_Charset){
print "Content-type: text/html; charset=$G_Charsetnn";
}else{
print "Content-type: text/htmlnn";
}
print "<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">"."n";
print "<html lang=ja>n<head>n";
if($G_Charset){ print "<meta http-equiv="Content-Type" content="text/html; charset=$G_Charset">n"; }
&Jprint ("<title>$G_title</title>n");
foreach (@G_styles){ print "<link rel="stylesheet" type="text/css" href="$_">n"; }
print "</head>n<body>n";
print "<div class=head>n";
&Jprint ("<h1>$G_title</h1><hr>n");
&printlinks;
print "<hr></div>n";
}
sub printFooter{
print "<div class=foot><hr>n";
&printlinks;
print "<hr>n";
open(IN, "../../sig.txt");
while (<IN>) { print; }
close(IN);
print "</div>n";
print "</body></html>n";
}
sub printlinks{
print "<a href="../../../index.htm">Home</a>n";
print "/n<a href="../../">Perl</a>n";
print "/n<a href="../">TestCGI Index</a>n";
if($G_linkFile){ &Jprint ("/n<a href="$G_linkFile">$G_titleの解説</a>n"); }
}
sub Jprint{
foreach (@_){ print &Jconvert($_, $G_Code, $G_myCode); }
}
sub JconvPrint{
foreach (@_){ print &Jconvert($_, $G_Code, &Jgetcode($_)); }
}
|