Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Zip without dir path

by Lotus1 (Chaplain)
on Dec 14, 2012 at 18:50 UTC ( #1008891=note: print w/ replies, xml ) Need Help??


in reply to Zip without dir path

The addFile method allows you to add a second parameter with a new name for the file, that is what it will be called inside the zip file. You can use File::Basename to get just the filename from $memberName.

foreach my $memberName (map { glob } $indir) { if (-d $memberName ) { if($zip->addFile( $memberName ) != AZ_OK){ #or sendalert(); $message = "Can't add file $memberName\n";} } }

This is using -d $memberName to test for directories. The addFile method is for adding a file, there are other methods for adding directories. I am surprised to see this since you said all works well in this script. Also, I'm surprised to see the glob statement by itself.


Comment on Re: Zip without dir path
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2015-07-04 17:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls