Hi Everyone,
I am new in perl programming can anyone help me to give a right way to do in this program
"Zip all .* file from a one windows directory to another directory."
Here is my code.
[CODE=perl]#!\usr\bin\perl
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
use File::Copy;
$Inpath = "M:\\SAPCONV\\S taging\\scripts \\";
print ".pl files in $Inpath are:\n";
opendir(DIR, $Inpath) or die "Can't open $Inpath: $!";
while( defined ($file = readdir DIR) ) {
print "glob param: $file\n" if -T "$Inpath/$file";
}
closedir(DIR);
$OutPath = "G:\\sysouts\\" ;
$tempdir = $Inpath . "scripts\\temp\ \";
$zipfile = "scripts.zi p";
chdir $InPath;
@FileList = glob($file);
my $zip = Archive::Zip->new();
foreach (@FileList) {
$FilePathName = $_;
@PathnameParts = split /\\/, $FilePathName;
$ListCount = @PathnameParts;
$FileName = @PathnameParts[$ListCount-1];
print "Adding File...." . $FileName . "\n";
$zip->addFile( $FileName )
or do {
warn "Can't add file $FileName, $!\n";
}
}
my $status = $zip->writeToFileNam ed($OutPath.$zi pfile);
if ($status == AZ_OK) {
print "Zipping completed successfully\n" ;
} else {
print "Zipping completed with errors\n";
}[/CODE]
I am new in perl programming can anyone help me to give a right way to do in this program
"Zip all .* file from a one windows directory to another directory."
Here is my code.
[CODE=perl]#!\usr\bin\perl
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
use File::Copy;
$Inpath = "M:\\SAPCONV\\S taging\\scripts \\";
print ".pl files in $Inpath are:\n";
opendir(DIR, $Inpath) or die "Can't open $Inpath: $!";
while( defined ($file = readdir DIR) ) {
print "glob param: $file\n" if -T "$Inpath/$file";
}
closedir(DIR);
$OutPath = "G:\\sysouts\\" ;
$tempdir = $Inpath . "scripts\\temp\ \";
$zipfile = "scripts.zi p";
chdir $InPath;
@FileList = glob($file);
my $zip = Archive::Zip->new();
foreach (@FileList) {
$FilePathName = $_;
@PathnameParts = split /\\/, $FilePathName;
$ListCount = @PathnameParts;
$FileName = @PathnameParts[$ListCount-1];
print "Adding File...." . $FileName . "\n";
$zip->addFile( $FileName )
or do {
warn "Can't add file $FileName, $!\n";
}
}
my $status = $zip->writeToFileNam ed($OutPath.$zi pfile);
if ($status == AZ_OK) {
print "Zipping completed successfully\n" ;
} else {
print "Zipping completed with errors\n";
}[/CODE]
Comment