[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Can't get sendmail to put subject right...



> > I indeed read all those dest[0]'s from a file, and such the \n character
>> is in the end.
>> Solved it by removing the extra \n in the end of the To-command. (I, for
>> some reason, don't like that chomp command).
>
>If you ever have a $dest[0] without a newline at the end, I hope you won't
>have to ask the list why your headers are ending up on the same line...
>
>You should chomp $dest[0] and print the newline explicitly.

I was more or less idlely following this thread, when it got me to 
thinking.  This is a case where you very much want to know the exact 
state of something ($dest[0] in this case) so you know how to proceed.

Chomp is good for dealing with 0 or 1 newlines, but what if there are 
43 newlines at the end of $dest[0]?

I came up with two solutions that seem fairly robust to me:

1) Chomp until done:
for($l = chomp $dest[0]; $l; $l = chomp $dest[0]) { }

The only problem with this is what if there are (multiple) newlines 
embedded within $dest[0]?  This may seem ridiculous, but consider the 
case where $dest[0] ends with two newlines followed by a space? 
Thus, my other solution is:

$dest[0] =~ s/\n/ /g;

This assumes that completely eliminating a newline within a list of 
multiple addresses might be bad, but that excess whitespace is not a 
problem.  I believe this to be true, but am not that much of a 
sendmail expert.

Comments?

-David Steffen-
David Steffen, Ph.D.
President, Biomedical Computing, Inc. <http://www.biomedcomp.com/>
Phone: (713) 610-9770 FAX: (713) 610-9769 E-mail: steffen@biomedcomp.com

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org