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);
}
精彩评论