在 Windows 上从与 Perl 中的某些正则表达式匹配的目录中删除所有文件的最短和最好的方法。
我的例子:全部删除*.txt目录中的文件,但保留tmp.txt?视窗。
*.txt
tmp.txt
chdir $dir or die $!; unlink grep { $_ ne 'tmp.txt' } <*.txt>;