Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Archive::ZIP - Zip selection of files

by Corion (Patriarch)
on Apr 10, 2015 at 09:46 UTC ( [id://1123029]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Archive::ZIP - Zip selection of files
in thread Archive::ZIP - Zip selection of files

Have you considered what ->addTree is actually doing? It is not a function that purely returns information.

I think you should rethink your approach and consider getting two lists, one list of the files in the archive and one list of the files not in the archive, then eliminate the members in both lists (see perlfaq4) and then add the appropriate number of remaining files to the archive.

Replies are listed 'Best First'.
Re^6: Archive::ZIP - Zip selection of files
by gmaniac (Initiate) on Apr 10, 2015 at 10:06 UTC
    Thank you for your reply. You're right. But
    @files = $zip->memberNames();
    does exactly what I want. I have all the file names and paths in the array. And with:
    @file = splice @files, 1, 50;
    I reduce the information before it's written to an archive. I want to select before I write and have the names, that's why comparing is not my goal. It's curious why
    foreach $line (@file) { $fileend = (split(/\./,"$line"))[-1]; if (($fileend eq "jpg") || ($fileend eq "txt")) { $zip->addFile("$line"); }
    doesn't do the job. Any explanation to this?

      Your program as shown still contains the line:

      @files = $zip->addTree( "$zippath" );

      This will always add all files.

        Well, if this is the case, I have to find another solution to fill my array. Thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1123029]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-24 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found