foreach my $file (@taxonomy_file_url) { if (-e $file) # does the file exist { unlink($file) #delete it } &getFile($file, "taxonomy", $local_taxonomy_directory); }