リメイク:ファイルから読み込む

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

use strict;
use warnings;

use CGI;
use FileHandle;

{
    my $cgi    = CGI->new;
    my $styles = ["../../ipp.css"];

    &amp;print_header($cgi, "テスト2", $styles);

    print $cgi->p("「sig.txt」を読み込みます。");

    print $cgi->start_div;
    my $fh = FileHandle->new("../../sig.txt") or die;
    print $fh->getlines;
    undef $fh;
    print $cgi->end_div;

    &amp;print_footer($cgi);
}

exit;

# ヘッダ
sub print_header {
    my ($cgi, $title, $styles) = @_;

    print $cgi->header({ -charset => "euc-jp" });
    print $cgi->start_html({
            -lang  => 'ja',
            -title => $title,
            -style => { src => $styles },
        });
    print $cgi->h1($title);
}

# フッタ
sub print_footer {
    my ($cgi) = @_;

    print $cgi->hr;
    print $cgi->div(
            $cgi->a({ href => "../../../" }, "Home"),
            "/",
            $cgi->a({ href => "../../" }, "Perl"),
            "/",
            $cgi->a({ href => "../" }, "TestCGI Index"),
        );
    print $cgi->hr;
    print $cgi->address(
            $cgi->a({ href => q{mailto:nobu3@x.age.ne.jp}}, "Written by Nobu3"),
        );
    print $cgi->end_html;
}
                          </div>
comments powered by Disqus
Built with Hugo
テーマ StackJimmy によって設計されています。