使用perl删除不同的文件,该名称以diefferent名称扩展而结束,例如动态日期和小时
我想删除目录中的许多文件。问题是扩展不相同。结尾是动态的: .DAT_20220526_061224
.DAT_20220525_041226
.DAT_20220514_081212
此扩展名是动态的,但是有相同的模型
,请有人可以帮助我 谢谢!
这是我的代码
use strict;
use warnings;
my $dir = "D:/perl-projet/";
if ( -e $dir)
{
unlink $dir . "log.dat_20220518_233007"; #this ligne is work quand i put all name of the file ( the was been deleted)
#unlink(glob("${$dir}log.dat_???)); #this ligne didn"t work
#unlink glob "$dir/*.dat_"; # this ligne didn"t too
}
I want to delete many file in my directory the problem is that the extension of that is not the same. the end is dynamic like:
.dat_20220526_061224
.dat_20220525_041226
.dat_20220514_081212
this extension is dynamic is change but there have same model
please somebody could help me
thanks!
this is my code
use strict;
use warnings;
my $dir = "D:/perl-projet/";
if ( -e $dir)
{
unlink $dir . "log.dat_20220518_233007"; #this ligne is work quand i put all name of the file ( the was been deleted)
#unlink(glob("${$dir}log.dat_???)); #this ligne didn"t work
#unlink glob "$dir/*.dat_"; # this ligne didn"t too
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
或
或
or
or