|
|
| Do you know where your variables are? | |
| PerlMonks |
Re: Rename files with $EDITORby hossman (Parson) |
| on Jul 31, 2010 at 05:02 UTC ( #852217=note: print w/ replies, xml ) | Need Help?? |
|
The idea behind this script both terrifies, and excites me. The script itself however frightens me, because there are some edge cases that can have some relaly nasty behavior...
I think the only safe way to deal with all of this is that if you detect your $target is already a key in the hash, you need to mv($target,$tmpfile) and then update the hash, ala: $files{$tmpfile} = $files{$target}; delete $files{$target};. It complicates things because you can't do a simple loop over a one time copy of the keys, but that's not a big deal. Just do a "while (keys %files) { $fname = (keys %files)[0]; ...; delete $files{$fname}; }" type flow instead.
In Section
Cool Uses for Perl
|
|
||||||||||||||||||||||||