Solved

rmtree

Posted on 2009-05-13
2
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Six Sigma Control Plans

691 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