Solved

rmtree

Posted on 2009-05-13
2
273 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now