} elsif ($size < $length) { my $rolled_log = "$logfile.1"; if(-e $rolled_log){ open(LOG, $rolled_log) || die "couldn't open file"; seek (LOG, $length+1,0); my $data_to_send = ""; while(){ $data_to_send .= $_; } close LOG; open LOG, $logfile || die "Couldn't open logfile"; seek (LOG, $length+1,0); while(){ $data_to_send .= $_; } my $smtp=Net::SMTP->new($smtpserver,Timeout=>30); $smtp->mail($from); $smtp->to($to); $smtp->data(); $smtp->datasend("From: $from\n"); $smtp->datasend("Subject: $applicationname Error\n"); $smtp->datasend("\n$data_to_send"); $smtp->dataend(); $smtp->quit(); open FILE, ">$lengthfile" || die "Couldn't open lengthfile for writing"; print FILE $size; close FILE; }