The following is the code I'm having trouble with. I am reading a text file with 5 lines in it. Each line contains a variable=value with a new line at the end. Some of these files have a variable that equals nothing, in which case I want the sub sendemailspecial to run. If the two contain values, then sub sendemailnormal. Unforturnately the if statement does not appear to be working. Thanx for anyone's help and suggestions.
############## 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; }

In reply to Funny if else problem by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.