在我的Perl脚本中,我LWP::Simple::getstore用来检索图像并存储为文件.但在存储如何检查该文件是否已存在之前?
这是片段
use constant FILE_DIR => "/home/destination/files/";
my $image_path = FILE_FOLDER."$item_id"."_"."$file_date.$image";
my $res = LWP::Simple::getstore($image_url,$image_path);
Run Code Online (Sandbox Code Playgroud)
请帮我解决一下这个.
谢谢
您可以使用文件测试,例如
unless (-e $image_path) {
LWP::Simple::getstore($image_url, $image_path);
}
Run Code Online (Sandbox Code Playgroud)