When you're working under use strict; (which is a good thing), you need to let Perl know when you're starting the use of a new variable, by declaring it with my or our, or using use vars. In your case, the problem is actually more subtle, as you're using <<EOF which tells Perl that what follows is to be a string until it sees EOF on a line by itself.

You'll also need to move the format call to whatever is sending the message to the sendmail. (as it works on filehandles... see the documentation on write ... I apologize, as I probably should have explained it better -- (if we compare 'write' to 'printf', there's no function equivalent to a 'write' version of 'sprintf' that I know of))

However, I'm more surprised that you said that lining up the text in the code didn't result in them being lined up in the e-mail. It's possible that the sendmail() function that you're using may be corrupting something, or not sending the message as plain text. If so, no matter how much work you do to get it looking pretty as plain text, something else is mangling it.


In reply to Re^3: Email Formatting by jhourcle
in thread Email Formatting by b310

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.