in reply to close statement issue
open (MAIL,"| /usr/sbin/sendmail || die "$!";) should be open (MAIL,"| /usr/sbin/sendmail") || die "$!"