- 論壇徽章:
- 307
|
本帖最后由 sunzhiguolu 于 2017-04-17 16:42 編輯
回復(fù) 7# zhouzhen1
非常感謝您的幫助,按照您提供的思路能夠?qū)⒙窂较碌?htm 文件讀出來(lái)了。由于文件名中包含一些特殊字符導(dǎo)致 在實(shí)際讀取文件時(shí)遇到了一些問(wèn)題。
badFileName1.jpg (17.73 KB, 下載次數(shù): 349)
下載附件
Bad-FileName
2017-04-17 16:34 上傳
測(cè)試代碼如下:
- #!/usr/bin/perl
- use strict;
- use warnings;
- use File::Spec::Functions;
- use Win32::LongPath;
- my $wkPath = $ENV{'TEMP'};
- my $dir = Win32::LongPath->new();
- if($dir->opendirL($wkPath)){
- foreach(grep /\.html?\z/i, $dir->readdirL()){
- $_ = catfile($wkPath, $_); #Output: drive:\path\filename.ext
- print("{$_}");
- print "\t", -e ? "(exists)" : "(not exists)", ".\n";
- }
- }
復(fù)制代碼 實(shí)際輸出結(jié)果:
![]()
|
|