[sf-perl] getting the salutations out of an email.

George Hartzell hartzell at alerce.com
Thu Oct 4 09:09:39 PDT 2012


Richard Reina writes:
 > I have a text files that need to be word wrapped neatly so they can be
 > turned into emails. They consist of:
 > 
 > Dear (or Hello) Jim,
 > 
 > Nice meeting with you on Thursday.  Blah
 > blah, blah.
 > blah, blah, blah,
 > 
 > Thanks,
 > 
 > Richard
 > 
 > Text::Wrap does a great job in breaking up and wrapping the lines my
 > problem is that since it removes all the "\n" s
 > I end up with:
 > 
 > Dear Jim, Nice meeting with you on Thursday.  Blah
 > blah, blah.
 > blah, blah, blah, Thanks, Richard
 > 
 > To counter this I began writing various conditionals that try to guess the
 > first and last lines of the file so that they can be preserved separately
 > and added after Text::Wrap has done it's work.  However, it's very
 > convoluted and I am not so confident it will work.  So I am wondering if
 > anyone know of a better way to accomplish the task?

At the simple end of the spectrum, how about just running the message
text through fmt (/usr/bin/fmt on mac os and freebsd).

At the other end of the spectrum, how about using Markdown in the
source text file and then running it through a converter.  That'll
open the entire world of Email-MIME-Kit
(http://search.cpan.org/dist/Email-MIME-Kit/).

g.


More information about the SanFrancisco-pm mailing list