I have a program that is run on numerous AIX servers, that will collect information and then compare it to the previous day’s info. It will then email a list of any differences.

I am running into an issue where a new line will not always print after certain statements. It appears to be an issue with certain variables that are presented in these print statements. The strange thing is if I take the program through debug and view the array it shows that each statement is on a new line. The log prints correctly, but the email does not. Code:

$message = "A difference in /opt/local/bin has been noted: $opt_local_ +bin{$file}{'new'}{'file'} is now available\n"; push @messages, $message;
then I will present them in a single variable and email them:
$message = join('',@messages); $subject = "CM Audit Daily Changes Notification"; &mail_admin($subject,$message);
The result I get from this is, where *NEWLINE* is the next difference the program finds:
A difference in /opt/local/bin has been noted: clean_oratab is no longer available *NEWLINE*A change in /etc/hosts has been detected. 10.40.250.3 r2dmn1 # regatta 2 domain 1 switch is no longer available

If I join with a new line ($message = join('\n',@messages);) I get:
A difference in /opt/local/bin has been noted: clean_oratab is no longer available

A change in /etc/hosts has been detected. 10.40.250.3 r2dmn1 # regatta 2 domain 1 switch is no longer available

But I do not want the whitespace between the lines.

If I use ‘’ between the variable and end of the line it works, but it prints the ‘’:

$message = "A difference in /opt/local/bin has been noted: ‘$opt_local +_bin{$file}{'new'}{'file'} is now available’\n"; push @messages, $message;
gives the following result:

A difference in /opt/local/bin has been noted: ‘clean_oratab is no longer available’
A change in /etc/hosts has been detected. 10.40.250.3 r2dmn1 # regatta 2 domain 1 switch is no longer available

Obviously it is something in the variable output on certain lines. But again it only affects the emailed results, not anything I can see in debug or the log files which is an exact copy of what is sent to the email program.

Any ideas before I give up?


In reply to New Lines are not printing after certain messages by tbest4475

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.