Okay. I am having a problem with this program hanging up after it ZIP's the 3 files. I can't hit CONTROL C||A..Z to end the program. I have to totally end the command prompt application. Let me explain the background of this code. I have an array of email address and each one is to recieve a particular file. Due to the large size of the file and the small size of their mailboxes, I must ZIP the files in order for them to recieve all of their material. I believe that the program can be followed from there. I do realize that there is probably an easier way to do what I am trying to do, and I will not shun any advice. But, my main concern is what is going on with the "hanging" issue.
And just in case you are wondering why "pkzip", my supervisor wanted to use it rather than "winzip" or anything else.
Thanks.
Blacksmith
#!Perl -w
use strict;
use Mail::Sender;
use Win32;
use Win32::Process;
use File::Basename;
my $cmd = "C:\\Program Files\\pkzip.exe";
my $time = localtime;
my $subj_line = "Price Change Worksheet for $time";
my %file = ('me@here.com'=>'P:\\TEXT\\ABC\\PCW-010.TXT','him@home.com'
+=>'P:\\TEXT\\ABC\\PCW-021.TXT','her@work.com'=>'P:\\TEXT\\ABC\\PCW-02
+4.TXT');
my $work = 'me@here.com';
foreach (keys %file) {
my ($name,$path,$suffix)=fileparse($file{$_},"\.[^.]*");
my $filename = "C:\\a\\$name";
sub print_error() {
return Win32::FormatMessage( Win32::GetLastError() );
}
my $root = $file{$_};
Win32::Process::Create(my $processobj,
"$cmd",
"pkzip $filename $root",
0,
DETACHED_PROCESS,
".") or print_error();
my $sender = new Mail::Sender( {from => $work ,smtp => 'mail.email.com
+'}) or die "$Mail::Sender::Error\n";
$sender->MailFile(
{to => $_,
subject => $subj_line,
msg => "This is a test for \n zip files.",
file => $filename})
and print "Mail sent OK." || die "$Mail::Sender::Error\n";
$sender->Close;
}