我想做的是收集所有 UTF16 Unicode 图表。我从http://unicode.org/charts/PDF/下载了所有 pdf 文件,并决定使用 perl 删除所有特殊的或 UTF32 图表,并使用以下脚本:
#!/usr/bin/perl
opendir(my $dir, ".");
my @files = grep {!/^U[0-9,A-F]{4}\.pdf/ && !/utf16only.pl/} readdir($dir);
for $f (@files)
{
print "deleting $f...\n";
#unlink $f;
}
closedir($dir);
当我运行脚本时,我得到以下输出:
C:\Users\Evan\Downloads\Unicode 6.1 Charts>utf16only.pl
deleting ....
deleting .....
deleting 10FF80.pdf...
deleting ErrorLink.pdf...
deleting U10000.pdf...
deleting U100000.pdf...
deleting U10080.pdf...
deleting U10100.pdf...
deleting U10140.pdf...
deleting U10190.pdf...
deleting U101D0.pdf...
deleting U10280.pdf...
deleting U102A0.pdf...
deleting U10300.pdf...
deleting U10330.pdf...
deleting U10380.pdf...
deleting U103A0.pdf...
deleting U10400.pdf...
deleting U10450.pdf...
deleting U10480.pdf...
deleting U10800.pdf...
deleting U10840.pdf...
deleting U10900.pdf...
deleting U10920.pdf...
deleting U10980.pdf...
deleting U109A0.pdf...
deleting U10A00.pdf...
deleting U10A60.pdf...
deleting U10B00.pdf...
deleting U10B40.pdf...
deleting U10B60.pdf...
deleting U10C00.pdf...
deleting U10E60.pdf...
deleting U10FF80.pdf...
deleting U11000.pdf...
deleting U11080.pdf...
deleting U110D0.pdf...
deleting U11100.pdf...
deleting U11180.pdf...
deleting U11680.pdf...
deleting U12000.pdf...
deleting U12400.pdf...
deleting U13000.pdf...
deleting U16800.pdf...
deleting U16F00.pdf...
deleting U1B000.pdf...
deleting U1D000.pdf...
deleting U1D100.pdf...
deleting U1D200.pdf...
deleting U1D300.pdf...
deleting U1D360.pdf...
deleting U1D400.pdf...
deleting U1EE00.pdf...
deleting U1F000.pdf...
deleting U1F030.pdf...
deleting U1F0A0.pdf...
deleting U1F100.pdf...
deleting U1F200.pdf...
deleting U1F300.pdf...
deleting U1F600.pdf...
deleting U1F680.pdf...
deleting U1F700.pdf...
deleting U1FF80.pdf...
deleting U20000.pdf...
deleting U2A700.pdf...
deleting U2B740.pdf...
deleting U2F800.pdf...
deleting U2FF80.pdf...
deleting U3FF80.pdf...
deleting U4FF80.pdf...
deleting U5FF80.pdf...
deleting U6FF80.pdf...
deleting U7FF80.pdf...
deleting U8FF80.pdf...
deleting U9FF80.pdf...
deleting UAFF80.pdf...
deleting UBFF80.pdf...
deleting UBOOP.pdf...
deleting UCFF80.pdf...
deleting UDFF80.pdf...
deleting UE0000.pdf...
deleting UE0100.pdf...
deleting UEFF80.pdf...
deleting UF0000.pdf...
deleting UFFF80.pdf...
前 2 行仍然是.
并且..
,我认为因为我正在尝试 unlink .
,它正在删除大量我不想删除的文件。我不确定问题是否出在我的正则表达式 , grep
,readdir
或unlink
上,但它删除的文件比它应该删除的多得多。