How can I send the content of file as email in Perl?
email, file, perl
Solution
You can just slurp up the contents of the file like so and use it as you would any other string:
open my $fh, '<', 'file.txt' or die "Ouch: $!\n";
my $text = do {
local $/;
<$fh>
};
close $fh or die "Ugh: $!\n";
print $text,"\n";
Problem
I have a log that gets created from a bunch of cron jobs. My task now is to send specific logs (e.g. error outputs) as an email. What is the best way to get content from a file and send it as an email? I have already figured out how to send email in perl. I just need to figure out how to read in the file and put it as the text of the email.