Welcome markuswinter,
I have modified your code to my style, but the one difference is that I have replaced the '$_' with '$file'. Using '$_' in a one-liner is fine, but when you use it multiple times, you may be changing the value of '$_'. I did not test your code, so it may work fine.
Since you are new to Perl, I'm just suggesting an alternate way to do this. I have changed this style several times in the past 15 years and all because when you have a multi-thousand line script and the compiler tells you that your 'Missing a right curly...' you start looking for ways to improve your style. YMMV.
foreach my $file (@taxonomy_file_url) { if (-e $file) # does the file exist { unlink($file) #delete it } &getFile($file, "taxonomy", $local_taxonomy_directory); }
You don't show 'getFile', but it must be testing for the existence of the file, so you might just remove that code since an 'open' with '>' will over-write the original file.
Good Luck
"Well done is better than well said." - Benjamin Franklin
In reply to Re: Correct code for deleting old file?
by flexvault
in thread Correct code for deleting old file?
by markuswinter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |