Right, Archive::Zip's job is to handle zip files, not delete things. But fortunately there is a core module that will make the deletion trivial:
use File::Path qw/remove_tree/;
remove_tree(@paths);
Where @paths are the paths/files you included in your Archive::Zip.
See File::Path for more information, including a description of error handling.
| [reply] [d/l] [select] |
Are you looking for unlink?
unlink 'file01.dat';
| [reply] [d/l] |
Are you looking for unlink?
I doubt the OP was looking for unlink, as they specifically asked how to delete files and directories, and unlink only deletes regular files1.
____________
1 unlink can delete directories under certain somewhat unusual conditions, but such use is not recommended. From unlink:
Note: unlink will not attempt to delete directories unless you are superuser and the -U flag is supplied to Perl. Even if these conditions are met, be warned that unlinking a directory can inflict damage on your filesystem. Finally, using unlink on directories is not supported on many operating systems. Use rmdir instead.
rmdir only deletes empty directories, and its documentation specifically suggests File::Path, as I've already suggested.
| [reply] [d/l] [select] |