Dear All,

            I have faced the problem using the Zip and unzip the files using the perl  
"Archive::Zip::Tree;"


Code :


#!/bin/perl -w
#use strict;
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
use Archive::Zip::Tree;

my $zipName = shift(@ARGV);
my $zip = Archive::Zip->new();
my $targetname;
open("AA","C:\\temp\\tempzip.txt");
@AA = <AA>;
$s = scalar(@AA);
$/ = "\n";

print "Total Elements :  $s \n";
$zipName = "c:\\temp\\Pons1.zip";
foreach my $a(@AA)
{
      chomp($a);
                $memberName = $a ;
      $targetname = '/archive'. $a ;
      if (-d $memberName )
      {
            print "Directory: $targetname \n";
            warn "Can't add tree $targetname\n"
                  if $zip->addTree( $memberName, $targetname) != AZ_OK;
      }
      else
      {
            print "FILE:  $targetname \n";
            $zip->addFile( $memberName)
                  or warn "Can't add file $memberName\n";
      }
}

my $status = $zip->writeToFileNamed($zipName);
exit $status;


Values in the C:\\temp\\tempzip.txt

\TEMP\aa.txt
\TEMP\dir1\aaaaa,txt
\PONS\dir1\pons.txt


Problem:

            After executing the above program i can get the zip file . But in the path 
still it is showing \TEMP\aa.txt . Actually in the script i changed the  target name 
by this statement      $targetname = '/archive'. $a ;
What i expect is that, the path has to be \archive\TEMP\aa.txt
                                     \archive \TEMP\dir1\aaaaa,txt
                                      \archive\PONS\dir1\pons.txt

Why i need this is ?

            When i am trying to extract the above mentioned zip file using the method 
call

            $zip->extractTree();

            I can not call this method without the root value to this method .( I 
thing am i right , i tried that also . When i trying to execute the unzip program to 
extract the zip file generated using the above program , it is saying

****        error: root arg missing in call to extractTree()
        Archive::Zip::Archive::extractTree('Archive::Zip::Archive=HASH(0x1bdf15c)') 
called at d:\unzip.pl line 28


The problem is that, how will i know the root argument in the zip file ( which is 
coming from some remote site ).

Please help me on this.


With Regards,
Pons.
____________________________________________________
Ponnambalam. M.A.
Philips Medical Systems,
Philips Innovation Campus,
#1,Murphy Road, Ulsoor.
Bangalore - 560008. INDIA
Phone : +91- 080 - 557 9000 Extn: 1013
E-mail: [EMAIL PROTECTED]
____________________________________________________


_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to