开发者

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

开发者 https://www.devze.com 2023-03-29 10:03 出处:网络
In my Perl script I am using LWP::Simple::getstore to retrieve an image and store as file. But before storing how to check if that f开发者_开发技巧ile already exists?

In my Perl script I am using LWP::Simple::getstore to retrieve an image and store as file. But before storing how to check if that f开发者_开发技巧ile 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, e.g.

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

精彩评论

暂无评论...
验证码 换一张
取 消