简体   繁体   English

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

[英]Perl LWP::Simple::getstore How to check if the file exists in destination directory

In my Perl script I am using LWP::Simple::getstore to retrieve an image and store as file. 在我的Perl脚本中,我使用LWP::Simple::getstore检索图像并将其存储为文件。 But before storing how to check if that file already exists? 但是在存储之前如何检查该文件是否已经存在?

this is the snippet 这是片段

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); 

Please help me with this. 请帮我解决一下这个。

Thanks 谢谢

You can use a file test , eg 您可以使用文件测试 ,例如

unless (-e $image_path) {
    LWP::Simple::getstore($image_url, $image_path); 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM