ファイルを作って飛ばす

                             <p>ソースコード</p>
 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
#!/usr/bin/perl

# require Jcode;
# *Jgetcode = &amp;Jcode::getcode;
# *Jconvert = &amp;Jcode::convert;

require "../../../cgi-bin/jcode.pl";
*Jgetcode = &amp;jcode::getcode;
*Jconvert = sub { &amp;jcode::to($_[1], $_[0], $_[2]); };

$file = "ts0011";
$outfile = "$file.htm";
$infile = "$file.cgi";
$title = "$infileのソース";
$fcode = "sjis";
$mycode = &amp;Jgetcode("漢字");
$cutcode = "jis";

$title .= "($mycodeから出力)";

{
    open(OUT, "> $outfile");
    &amp;printHeader;

    print (OUT "<ol>");
    open(IN, $infile);
    while($line = <IN>){
        $line =~ s/&amp;/&amp;amp;/g;
        $line =~ s/"/&amp;quot;/g;
        $line =~ s/</&amp;lt;/g;
        $line =~ s/>/&amp;gt;/g;
        $line =~ s/ /&amp;nbsp;/g;
        &amp;Jfprint ("<li><code>$line</code>");
    }
    close(IN);
    print (OUT "</ol>");

    &amp;printFooter;
    close(OUT);

    print "Location: $outfilenn";

    exit;
}

sub printHeader{
    &amp;Jprint ("<html lang=ja><head><title>$title</title>n");
    print (OUT "</head><body>n");
    &amp;Jprint ("<h1>$title</h1><hr>n");
}

sub printFooter{
    print (OUT "<hr>n");
    print (OUT "</body></html>n");
}

sub Jprint{
    foreach (@_) {
        print (OUT &amp;Jconvert($_, $cutcode, $mycode));
    }
}

sub Jfprint{
    foreach (@_) {
        print (OUT &amp;Jconvert($_, $cutcode, $fcode));
    }
}
                          </div>
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy