I have a set of commands that run and if a difference is found it prints a message to an array and then sends that array in an email. certain messages are not printing the new line after the text. others are.
code:
Expand|Select|Wrap|Line Numbers
- $message = "A difference in /opt/local/bin has been noted: $opt_local_bin{$file}{'new'}{'file'} is now available\n";
- push @messages, $message;
Expand|Select|Wrap|Line Numbers
- $message = join('',@messages);
- $subject = "XXXXXX";
- &mail_admin($subject,$message);
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
These lines print right next to each other with out a new line.
if i join with a '\n' then it will print a seperate line, but alos a blank liner between them:
Expand|Select|Wrap|Line Numbers
- $message = join('\n',@messages);
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
I do not want the whitespace between them.
if i take the program through debug, all the way to the end an view @messages or $message everything is spaced correctly.
if i add '' between the command and the end of the message it will print correctly, but leaves the ''.
code:
Expand|Select|Wrap|Line Numbers
- $message = "A difference in /opt/local/bin has been noted: '$opt_local_bin{$file}{'new'}{'file'} is now available'\n";
- push @messages, $message;
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
Any ideas before i give up?