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;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.