Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

archive::zip how to delete files after creating the zip.

by chandru210486 (Initiate)
on Jun 30, 2013 at 00:52 UTC ( #1041532=perlquestion: print w/ replies, xml ) Need Help??
chandru210486 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, i am using archive::zip module to create zip file. But, it is not deleting the files/directories after creating the zip. Please let me know how can i do that in archive::zip.

Comment on archive::zip how to delete files after creating the zip.
Re: archive::zip how to delete files after creating the zip.
by rjt (Deacon) on Jun 30, 2013 at 01:07 UTC

    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.

Re: archive::zip how to delete files after creating the zip.
by lithron (Chaplain) on Jun 30, 2013 at 03:27 UTC
    Are you looking for unlink?
    unlink 'file01.dat';

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1041532]
Approved by rjt
Front-paged by rjt
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2014-09-21 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (166 votes), past polls