#!/usr/bin/perl -w
#
# $Revision: 1.3 $ $Date: 2012-07-26 17:11:47-04 $
# $Source: /home/vogelke/bin/RCS/email-wrap,v $
# $Host: sys7.com $
# $UUID: 19f512e3-b2cc-3885-982a-763506cedf85 $
#
#<email-wrap: wrap long lines in the body of email messages.

use Text::Format;
use strict;

my $text = new Text::Format;
$text->columns(75);
$text->tabstop(0);
$text->firstIndent(0);

# Skip the first paragraph (should be the header)
while (<>) {
    chomp;
    print "$_\n";
    last unless length($_);
}

# Format everything else.
while (<>) {
    chomp;
    if (length ($_) > 90) {
        print $text->format($_);
    } else {
        print "$_\n";
    }
}

exit (0);
