2011-08-19 105 views
2

在我的Perl腳本中,我使用LWP::Simple::getstore來檢索圖像並將其存儲爲文件。但在存儲之前如何檢查該文件是否已經存在?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); 

請幫助我。

感謝

+0

'FILE_DIR' **和**'FILE_FOLDER'?這聽起來很混亂。 – TLP

回答

6

可以使用file test,例如

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