Reputation: 2264
Hi friends i can create a zip file using files which is there in the directory where the script is currently running now i want to create zip file from various directory can anybody help me? my code is;
use IO::Compress::Zip qw(:all);
zip [ glob("inventory_report_for_neus.xls") ] => "my.zip"
or die "Cannot create zip file: $ZipError" ;
this will produce zip file with specific files but
use IO::Compress::Zip qw(:all);
zip [ glob("..\\inventory_report_for_neus.xls") ] => "my.zip"
or die "Cannot create zip file: $ZipError" ;
this is also produce zip file but there is no file inside!
Upvotes: 3
Views: 12087
Reputation: 2264
friends finally i found solution for this case..simply i've used shell command inside perl so i'll create zip file with appropriate files...code as follows.
use strict;
use warnings;
use MIME::Lite;
use Net::SMTP;
my $msg = MIME::Lite->new (
From => '[email protected]',
To => '[email protected]',
Subject => 'with inline images',
Type =>'multipart/mixed'
) or die "Error creating mult;$!\n";
system("zip test.zip '../test_dir/report.xls'");
.
.
.
.
$msg ->( filename => test.zip,
content_type => 'application/zip',
disposition => 'attachment',
name => $filename,
);
MIME::Lite->send('smtp', 'smtp.gmail.com', Timeout=>60,AuthUser=>'xyz', AuthPass=>'remotecontrol');
$msg->send();
Upvotes: -2
Reputation:
Updated
IO::Compress::Zip
creates a zip file with a hierarchical structure based on the original locations of the files within the current directory.
However, a result of this is that it does not correctly handle files that are not enclosed by the current working directory.
The simplest solution is probably to change directories to the parent directory before zipping. If that is not an option, copy the files to a temporary location before zipping, or possibly use IO::Compress::Zip
's more advanced features, like writing the zip file from a filehandle.
Upvotes: 5