Hi there,
I'm trying to match a list of items and using sendmail to mail me only those matching strings from a file. This is the code I have so far:
The body of the email message is completely blank. However, my "print $match;" shows the strings that I am matching for. What is wrong with my code? Thanks.
-twantrd
I'm trying to match a list of items and using sendmail to mail me only those matching strings from a file. This is the code I have so far:
Code:
use FileHandle;
my $match;
# Grab the filenames that have been downloaded
open (FILENAME, "<$logfile");
while (my $match=<FILENAME>) {
if ($match =~ /Starts:/) {
print "$match"; # printing the files works
}
}
close (FILENAME);
my $mail=new FileHandle;
$mail->open("| /usr/sbin/sendmail -t") or die "Cannot open $!";
$mail->print("From: root\@host.mydomain.com\n");
$mail->print("To: $recipients\n");
$mail->print("Subject: Downloaded files\n");
$mail->print("*** Downloaded Files ***\n\nFiles: $match");
$mail->close();
The body of the email message is completely blank. However, my "print $match;" shows the strings that I am matching for. What is wrong with my code? Thanks.
-twantrd