0
#!/usr/local/bin/perl
use warnings;
use strict;
use utf8;
use Encode qw(encode);
my $dir = '/data/Delibes, Léo';
if (-d $dir) {
print "OK\n";
}
if (-d encode 'utf8', $dir) {
print "OK\n";
}
This print 2 times OK
;我想這是因爲Perl在內部存儲$dir
作爲utf8。如何測試PerlIO :: fse是否適用於文件測試運算符?
我有一種方法來檢查PerlIO::fse是否對文件測試運算符有影響,只要perl和文件系統存儲在utf8
?
編輯:
#!/usr/local/bin/perl
use warnings;
use 5.014;
binmode STDOUT, 'utf8';
use utf8;
my $dir1 = 'é';
my $dir2 = chr(0xE9);
opendir my $dh1, $dir1 or warn '1: ', $!;
say "OK1" if -d $dir1;
opendir my $dh2, $dir2 or warn '2: ', $!;
say "OK2" if -d $dir2;
utf8::upgrade($dir1);
utf8::upgrade($dir2);
opendir my $dh3, $dir1 or warn '3: ', $!;
say "OK3" if -d $dir1;
opendir my $dh4, $dir2 or warn '4: ', $!;
say "OK4" if -d $dir2;
# OK1
# 2: Datei oder Verzeichnis nicht gefunden at ./temp1.pl line 12.
# OK3
# OK4
也許我不完全瞭解如何PerlIO::fse
工作 - 在這個例子中,我不能看到PerlIO::fse
任何影響:
#!/usr/local/bin/perl
use warnings;
use 5.014;
binmode STDOUT, 'utf8';
use utf8;
use PerlIO::fse 'utf-8';
my $dir1 = 'é';
my $dir2 = chr(0xE9);
opendir my $dh1, $dir1 or warn '1: ', $!;
say "OK1" if -d $dir1;
opendir my $dh2, $dir2 or warn '2: ', $!;
say "OK2" if -d $dir2;
# OK1
# 2: Datei oder Verzeichnis nicht gefunden at ./temp1.pl line 13.