リメイク:自分の名前を調べる

                             <p>今回は、binmodeを使って、出力を「utf8」ということにしています。</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
#!/usr/bin/perl -T
# 日本語(utf-8)

use strict;
use warnings;
use utf8;
use CGI;

binmode STDOUT, q{:utf8};

# binmode STDOUT, q{:encoding(euc-jp)};

{
    my $cgi   = CGI->new;
    my $html  = qq{};
    my $title = qq{テスト5};
    $html .= $cgi->header( { -charset => q{UTF-8} } );

    #    $html .= $cgi->header( { -charset => q{EUC-JP} } );
    $html .= $cgi->start_html(
        {   -title => $title,
            -lang  => qq{ja},
        }
    );
    $html .= $cgi->h1($title);
    $html .= $cgi->start_div;
    if ( my $referer = $cgi->referer ) {
        foreach my $key ( sort keys %ENV ) {
            my $lc_key = lc $key;
            $lc_key =~ s/^http_//;
            my $value = "";
            eval { $value = $cgi->$lc_key() };
            unless ($@) {
                $html .= $cgi->p(
                    qq{環境変数「$key」の値は、「$value」です。}
                );
            }
        }
        $html .= $cgi->a( { -href => $referer }, q{戻る} );
        $html .= $cgi->h2(qq{参考});
        $html .= $cgi->p( join $cgi->br, sort keys %ENV );    # キーの一覧
    }
    else {
        $html .= $cgi->p(qq{情報の取得に失敗しました。});
    }
    $html .= $cgi->end_div . $cgi->end_html;

    print $html;
}
                          </div>
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy