Perl LWP :: Simple :: getstore如何检查文件是否存在于目标目录中

Bal*_*aji 2 perl file exists

在我的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)

请帮我解决一下这个.

谢谢

Eug*_*ash 6

您可以使用文件测试,例如

unless (-e $image_path) {
    LWP::Simple::getstore($image_url, $image_path); 
}
Run Code Online (Sandbox Code Playgroud)