Solved

rmtree

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Reading fields from the text file. 4 106
Perl Script - Remove row of data based on column value 3 77
How to get all the API from website? 11 160
create a gui in perl 3 112
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…
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…

734 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