I'm writing a webmail script and saving sent mail to a pipe delimited flat file like so:
The problem was line breaks from the textarea messing up the $body part. I tried many combinations of textarea properties and such but only $body=~s/\n/ /g; got it all on one line, but that solution ruined the formatting of the original message which needs to be preserved.print FILE "$when|$to|$from|$subject|$body\n";
My solution is to uuencode the contents of $body for saving, and uudecode $body for displaying. It seems to work very well but wonder if it's the best way or if there may be unforseen problems down the road.
Sample record:my $encoded_body = pack ("u", $body); $encoded_body=~s/\n//g; print FILE "$when|$to|$from|$subject|$encoded_body\n";
Decoding:Fri Dec 15 15:34:10 2000|to@net.net|from@net.net|Hello|E5&AI<R!I><R!T: +&4@><V%M><&QE(&UE><W-A9V4A#0H-"D)Y92X-"@`` >
Yields:$decoded_body = unpack ("u", $encoded_body);
thanks - epoptaiThis is the sample message! Bye.
In reply to uuencoding to deal with line breaks by epoptai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |