|Do you know where your variables are?|
A warning about passing mountpoints as arguments to directory recursion programmesby Don Coyote (Pilgrim)
|on Apr 26, 2013 at 14:05 UTC||Need Help??|
taint glad you mentioned this File::Find seems grossly inefficient for performing simple file tasks
Honing my understanding and skills, I have a script which accesses a mounted windows system and clears out temporary folders. Great for learning about recursion etc...
I set about providing myself with some default filepaths and mountpoints, lest i decide not to provide them as arguments to my script. The starting directories are in the file and the script runs through the paths and recursively unlinks the files under those directories.
I developed a nice little help parser
and set my default paths
so this works if no arguments are provided and sets the filepath if one argument is provided, using the default mountpoint.
I went back to clear up the edge case of an orphaned hyphen whilst requesting the usage info. At which point I realised the tremendous disaster which lay ahead, had I tested this on a singular argument consisting of either a filepath or mountpoint. Of course I had put die statements everywhere like a keen domino course constructor interspersing the frail light blocks with large heavy lumps of immutable iron. Debugger runs the code and dieing in source is a good way to reinforce your breakpoints.
Can you see what might conceivably go wrong here?
pass me some more rope please anyone?