in reply to unable to delete dat files from a folder in windows all users/norton folder

G'day 5plit_func,

Look at readdir for better and more concise ways to achieve what you're doing with respect to getting a listing of files. I suspect the two shifts are to remove the current and parent directories (i.e. '.' and '..'): the grep in the first example removes the need for these statements as well as the additional map in your code.

I'd recommend using the autodie pragma to check for problems (including opendir and unlink). The alternative is to hand-craft explicit checks throughout your code: this is time consuming, a lot more work and error-prone.

If the errors that now show up do not help you, please post them here so that we can see them. While it's good that you've posted your code, without seeing the output, error or otherwise, we're somewhat in the dark with regards to being able to provide help. [Take a look at the guidelines in "How do I post a question effectively?" if you're unsure what to post.]

If you're not doing this already, I'd strongly recommend setting up a test directory (perhaps with a script to recreate it) for trying out your code while you're in development mode. It's all too easy to accidently delete the wrong (possibly important) files.

-- Ken

Replies are listed 'Best First'.
Re^2: unable to delete dat files from a folder in windows all users/norton folder
by RichardK (Parson) on Nov 16, 2013 at 17:56 UTC

    glob / File::Glob is an even more concise way to get a directory listing.