linux - Linux - Perl - 文件不存在,但确实存在
问题描述
我有一个文件
/var/tmp/pcaps/言語をé¸æŠžã—ã¦ããŸã‚™.pcap'
这正是它的名字,它是用 UTF-8 编码的。
当我在上面运行 vim 时,它会按预期打开。
但是当我运行以下 perl 代码时:
if (-e $target_file) {
warn "the file exists\n";
} else {
warn "the file does not exist!\n";
}
$target_file 正是上面提到的文件。它进入其他地方。
为什么会这样?
解决方案
#use utf8;
my $file = 'è¨èªãé¸æãã¦ããã.pcap';
if(-e $file){
print "exists\n";
}
这对我有用。也许尝试“使用 utf8;”
编辑:
检查 $target_file 的完整路径。也许有一个错误的字母/文件夹?
推荐阅读
- javascript - 使用 tr.remove() 删除 HTML 表的行,提交按钮只发回它上面的行而不是它下面的行
- javascript - 在将大量值导入和分配给角度形式时,在潜在的内存不足崩溃(Chrome 浏览器)之前暂停
- linux - 添加日志文件命令会将脚本置于循环中?
- cassandra - 如何将谷歌云功能连接到 Kubernetes 集群中的 cassandra 数据库
- java - 搜索 char 数组以查看 char 是否匹配
- php - PHP Composer 自动加载不起作用,没有启动类
- c++ - 在 C++ 中将数组内容格式化为一系列字符串并输出到 .csv?
- postgresql - SQL 中每个 uuid 的固定时间戳范围
- ios - iOS IPA 网络分发延迟
- android - gradle,本地项目作为另一个项目的依赖项/基础