dragonz has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have some *.txt files, I can zip them separated, but I want to zip them in only one zip file. Please help me. Also I'm sorry for my english

Replies are listed 'Best First'.
Re: Zip file problems
by sh1tn (Priest) on Feb 08, 2005 at 16:10 UTC
    Take a look at Archive::Zip module.
    In its simplest form:
    my $zip = Archive::Zip->new(); #create object $zip->addFile( $_ ) for glob '*.txt';#addition of *.txt files $zip->writeToFileNamed( 'TXT.zip' ) #archive & compress
Re: Zip file problems
by Anonymous Monk on Feb 08, 2005 at 16:09 UTC
Re: Zip file problems
by dragonz (Initiate) on Feb 08, 2005 at 17:19 UTC
    I read Archive::Zip but I couldn't find what I was looking. I couldn't use the tip you gave me. the code I use for zipping is:
    use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); $namein = "$path\\$name"; $nameout = "$pathout\\AFJPWEB6_$anio$mes$dia\.zip"; print "Comprimiendo ", $namein,"\n"; my $zip = Archive::Zip->new() ; my $member = $zip->addFile( $namein ); my $status = $zip->writeToFileNamed( $nameout ); die "error somewhere" if $status != AZ_OK;
      so this zips a single file. if you want to add multiple files to the archive you will have to loop these.
      @names = ("name1", "name2"); $nameout = "$pathout\\AFJPWEB6_$anio$mes$dia\.zip"; print "Comprimiendo ", $namein,"\n"; my $zip = Archive::Zip->new() ; $zip->addFile( $_ ) for @names; my $status = $zip->writeToFileNamed( $nameout ); die "error somewhere" if $status != AZ_OK;
      holli, /regexed monk/
      I couldn't use the tip you gave me

      Why not? What is wrong with the example? And what are you looking for, if your (answered) question wasn't the question you wanted to ask?