2011-08-19 119 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); 
} 
相关问题