ファイルに書き出す

                             <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
#!/usr/bin/perl

@styles=("../../ipp.css","../test.css");
@wdays = ("日", "月", "火", "水", "木", "金", "土");

{
    &amp;printHeader("テスト3");

    print "「temp.txt」に書き出します。n";
    open(OUT,"> temp.txt");
    print(OUT "この文は temp.txt の中身になるはずです。n");
    print(OUT "書き込んだ時間は、");
    ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)
            = localtime(time);
    $date = sprintf("%04d/%02d/%02d(%s) %02d:%02d:%02d",
        $year + 1900, $mon + 1, $mday, @wdays[$wday], $hour, $min, $sec);
    print(OUT $date);
    print(OUT "です。n");
    close(OUT);
    print "<div class=test><a href="temp.txt">temp.txtを見る</a></div>";

    &amp;printFooter;

    exit;
}

sub printHeader{
    print "Content-type: text/htmlnn";
    print "<html lang=ja><head><title>$_[0]</title>n";
    foreach $st (@styles){
        print "<link rel="stylesheet" type="text/css" href="$st">n";
    }
    print "</head><body>n";
    print "<div class=head>n";
    print "<h1>$_[0]</h1><hr>n";
    print "<a href="../../../index.htm">Home</a> / <a href="../../">Perl</a> / <a href="../">TestCGI Index</a>n";
    print "<hr></div>n";
}

sub printFooter{
    print "<div class=foot>n";
    print "<hr>n";
    print "<a href="../../../index.htm">Home</a> / <a href="../../">Perl</a> / <a href="../">TestCGI Index</a>n";
    print "<hr>n";
    open(IN,"../../sig.txt");
    while ($sig=<IN>){print $sig;}
    close(IN);
    print "</div>n";
    print "</body></html>n";
}
                          </div>

Comments

comments powered by Disqus