[英]Perl & LWP: getstore() will only save a file if I don't specify a directory
[英]Perl LWP::Simple::getstore How to check if the file exists in destination directory
在我的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);
請幫我解決一下這個。
謝謝
您可以使用文件測試 ,例如
unless (-e $image_path) {
LWP::Simple::getstore($image_url, $image_path);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.