----------------------------
[small]ignore this section:
delete files
deleting files[/small]
----------------------------
Problem :
You want to delete all the files and sub folders (and all their files and sub folders) in a folder. But to delete files you need to use the unlink() function and for folders the rmdir() function, and besides, you don't know how to recursively search through all the sub folders to delete all the files first so you can delete all the folders.
Solution :
Use the [link http://perldoc.perl.org/File/Path.html]File:ath[/link] (core) module.
Discussion :
The module is so easy to use that there is really not much to discuss. Click on the link above and read the documentation. You can also use the module to create directory trees.
[red]Important Note[/red]
The only thing to keep in mind is that deleting files and folders is most likely going to be a permanent situation. So make sure you really want to delete an entire directory tree and make sure you are starting in the correct folder before invoking the script. If you make a mistake and start in the wrong directory you could suffer permanent loss of all the data.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.