if($#ARGV==-1) { #use current date $date='date--d'1 day ago'+'%Y-%m-%d''; chop($date); } else { print"USAGE: summary.pl[date yyyy-mm-dd]\n"; } $rptname="summary".$date.".txt"; print"Date: ",$date,"\n"; print"Report: ",$rptname,"\n"; open(RPT,">$rptname")||warn "Unable to open report file: $!\n"; #### use MIME::Lite; $msg=MIME::Lite->new( From =>'root@localhost.mycompany.com', To =>'myname@mycompany.com', Subject =>'Summary Report', Type =>'multipart/mixed'); $msg->attach(Type =>'TEXT', Data =>"Summary Report for yesterday"); $msg->attach(Type =>'TEXT', Path =>'$rptname', Filename =>'summary'.$date.'.txt'); $msg->send;