in reply to Re^4: newbie question to archive::zip
in thread newbie question to archive::zip
to something like:@values = split(/\|/,$case); $driveltr = $values[0]; $dira = $values[1]; $dirb = $values[2]; $unique_id = $values[3]; $case_num = $values[4]; $case_part = $values[5];
my ($driveltr, $dira, $dirb, $unique_id, $case_num, $case_part) = spli +t(/\|/,$case);
use strict; use warnings; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $file_path = "c:/temp/zip"; my @files = <c:/temp/zip/*.tif>; my $fileCount = scalar @files; print "We have $fileCount files to work with .. lets begin\n"; my %zips; my @items = map { chomp; s#(/|-|.tif)#|#g; lc } @files; # could just +do this in the foreach parens .. foreach my $case (@items) { my ($driveltr, $dira, $dirb, $unique_id, $case_num, $case_part) = +split(/\|/,$case); my $zip_file_name = "$file_path/$case_num.zip"; my $casePartStr = length($case_part) ? "-$case_part" : ""; my $file_name = "$unique_id-$case_num$casePartStr.tif"; my $file_to_zip = "$file_path/$unique_id-$case_num$casePartStr.tif +"; print "to the '$zip_file_name' zip file I will add '$file_name'\n" +; $zips{ $zip_file_name }->{ $file_to_zip } = $file_name; } while( my ($zip_file_name, $contents) = each %zips ){ my $zip = Archive::Zip->new(); while( my ($file_to_zip, $file_name) = each %$contents ){ zip->addFile( $file_to_zip, $file_name ); } die 'write error' unless $zip->writeToFileNamed( $zip_file_name ) == + AZ_OK; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: newbie question to archive::zip
by jashv (Initiate) on Apr 14, 2006 at 20:01 UTC | |
by jashv (Initiate) on Apr 18, 2006 at 19:12 UTC | |
by jashv (Initiate) on Apr 19, 2006 at 13:50 UTC | |
by jashv (Initiate) on Apr 19, 2006 at 15:21 UTC |