I am lost here. I have a program which automatically generates an email, based upon a particular configuration file. The way the program was written, it simply prints to <STDOUT>. I am trying to modify it to print to a temporary file, send an email who's body is this temporary file, unlinking the temporary file, then exit.

Here's some code:
use IO::File; my $fh = IO::File->new_tmpfile() || die "Can't make tmp file: $!"; my $FORMAT ="%-4s %-15s %-16s %-16s %-6s %-6s %-8s %s"; open (FILE, ">$fh")|| die "Can't open temp file: $!\n"; select ($fh); # this is an example of how I have coded all of my print statements ###################### # Print Router Table # ###################### print FILE <<TABLE The following table contains pertinent information regarding the routers listed in this flow request. TABLE ; printf FILE ($TAB, "Item", "Router", "Type", "IOS Version", "Memory", "Engine(s)", "\n"); printf FILE ($TAB, "====","================","====","===========", "=======","===========", "\n"); $counter = 0; foreach $key (sort keys %router_of_interest) { if (exists $version{$key} && $router_type{$key} && $memory{$key} && $engine{$key}) { $counter++; printf FILE ($TAB, "$counter.", "$key", "$router_type{$key}", "$version{$key}", "$memory{$key}K", "Engine $engine{$key}", "\n"); } }
Here's how I intend on sending mail
open(MAIL,"|/usr/lib/sendmail -t") || die "Can't open sendmail: $!"; print MAIL <<REQUEST To: <me\@work.com> Subject:Flow Export Request - $request_date REQUEST ; close(MAIL);
My question is how do I accomplish using my temporary file, "FILE", as the text of an my email?

Thanks, as always,

Steve

P.S. Yes, I'm using  use strict; and -w. All the above variables are declared, and contain the values that I expect :)

In reply to Using temporary file as body of email by Tuna

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.