Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
############## Initialize variables ################# $watcheddir="/samba/accpac/email"; chdir "$watcheddir"; use Mail::Sendmail; unshift @{$Mail::Sendmail::mailcfg{'smtp'}},'mail.aidusa.com'; ##################################################### ####### Translate salesperson number to name ######## %personname=('1001', 'Jerry Clavin', '1009', 'Mike Lay', '1020', 'Vern +on Simpson', '1030', 'Mike Manuel', '1040', 'Ted Zerbey', '1050', 'Mark Akin', '1060', 'Mike Hendricks', +'1500', 'Bill Taylor', '2003', 'House Account (OKC)', '2004', 'Vince Rada', '2007', 'Jerry Hopper', '2009', 'Bryan Montgome +ry', '3000', 'Mike Lay', '3100', 'Jerry Clavin', '5300', 'Mike Lay'); ##################################################### ##### Associate salesperson number with address ##### %personaddress=('1001', 'jclavin@aidusa.com', '1009', 'mlay@aidusa.com +', '1020', 'vsimpson@aidusa.com', '1030', 'mmanuel@aidusa.com', '1040', 'tzerbey@aidusa.com', '1050', 'makin@aidusa.com', '1060', 'mh +endricks@aidusa.com', '1500', 'btaylor@aidusa.com', '2003', 'jhopper@ +aidusa.com', '2004', 'vrada@aidusa.com', '2007', 'jhopper@aidusa.com', '2009', 'bm +ontgomery@aidusa.com', '3000', 'mlay@aidusa.com', '3100', 'jclavin@ai +dusa.com', '5300', 'mlay@aidusa.com'); ##################################################### ################## Monitor loop ##################### loop: opendir (DIR, $watcheddir); @files=grep {!/^\./} readdir (DIR);@files removing files that closedir DIR; foreach $currentfile (@files) { &filecontents; } sleep 10; goto loop; ##################################################### ########## Get Data from Printed File ############### ########## Send Message to Address ############### ########## Delete File After Success ############### sub filecontents { print "Current File: $currentfile\n"; $date=localtime(time); open FILE, $currentfile; $.=0; do { $firstline=<FILE>; ($name, $value)=split(/=/, $firstline); $value =~ s/^\s+//; $value =~ s/\s+$//g; $value =~ s/\n//g; print "$name\=$value\n"; $data{$name}=$value; } while $.<5; if ($data{'SONUMBER'} eq "" || $data{'SALESPERSON'} eq "") { $data{'SONUMBER'}="No S.O. attached"; $data{'SALESPERSON'}="No salesperson assigned"; &sendemailspecial; } else{ &sendmailnormal; } unlink $currentfile; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Funny if else problem (boo)
by boo_radley (Parson) on Jan 12, 2002 at 03:10 UTC | |
|
Re: Funny if else problem
by dereks (Scribe) on Jan 12, 2002 at 04:10 UTC | |
|
Re: Funny if else problem
by Anonymous Monk on Jan 12, 2002 at 16:01 UTC | |
|
Re: Funny if else problem
by Anonymous Monk on Jan 14, 2002 at 23:24 UTC |