开发者

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. 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜