Solved

rmtree

Posted on 2009-05-13
2
292 Views
Last Modified: 2012-05-06
so I'm trying to erase a subdirectory and its files with rmtree in a subroutine. After erasing it (if it exists) I recreate it. Following this, if the user of my program wants to erase it, I use rmtree once again to erase it again. For some reason when i have rmtree twice in that subroutine i get the following error:

Can't remove directory File exists in line 700

the first time I try to use rmtree I do it a few lines before, the second time I have rmtree it is in line 700.  Does somebody know how to debug this?! thanks! :)
0
Comment
Question by:cucugirl
2 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 500 total points
ID: 24377751
Are you passing the error variable?  If not, try using it.  If so, what is in it?


my @errors;
rmtree('/some/path/to/remove', error => \@errors);
die "Errors occurred:\n" . join("\n", @errors) . "\n" if @errors;

Open in new window

0
 

Author Comment

by:cucugirl
ID: 24377813
iI did not know about that error variable... I'll use that from now on. I spent a few hours trying to figure it out and i had an open filehandle from that same directory i wanted to remove. works now, but i'll definitely use this snippet from now on! thanks!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question