Perl

該頁面還沒有翻譯。

Perl是一個動態型別的程序設計語言

UTF-8支持

use strict;
use warnings;
use utf8;

binmode STDOUT, ':utf8';

my $hoge = "あいうえお";
print $hoge, "\n";
# length...5
print "length...", length($hoge), "\n";

文件輸入

use strict;
use warnings;
use utf8;

binmode STDOUT, ':utf8';

my $file = "hoge.txt";
open my $fh, "<:utf8", $file
  or die "Cannot open $file";

while (my $line = readline $fh) {
  chomp $line;
  print $line, "\n";
}
close $fh;

文件輸出

use strict;
use warnings;
use utf8;

my $file = "hoge.txt";
# 新規作成
open my $fh, ">:utf8", $file
  or die "Cannot open $file";
print $fh "あいうえお\n";
close $fh;

# 追記
open my $fh2, ">>:utf8", $file
  or die "Cannot open $file";
print $fh2 "\x{304B}きくけこ\n";
close $fh2;