Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

rmtree

Posted on 2009-05-13
2
Medium Priority
?
333 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 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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

636 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