in message <FA5A4B23-9904-4365-A5EA-6439AD69C873(_at_)kreme(_dot_)com>,
wrote LuKreme thusly...
On 21 Jan 2014, at 23:43 , LuKreme <kremels(_at_)kreme(_dot_)com> wrote:
| formail -I"" \
| grep -v "^>" \
| perl -e "$/ = undef; $_ = <>; s/\s+/ /sg; print substr $_, 0, 200"
In case of significant, important work being done on mail, it would
be best to save that in a file so that the script|program can be
easily tested.
When invoking perl, simply do the quote avoidance there too ...
#!/path/of/perl
use strict; use warnings;
# This programs is based on above quoted one. This does not send
# any mail on its own. It is expected to be given only the
# body of an email message.
#
# It prints a string of size of less than or equal to $max_char.
my $max_char = 200;
my $quote_re = qr{^ \s* >}x;
my $sign_re = qr{^ ---? \s* $}x;
my @body;
while ( my $line = <STDIN> )
{
$line =~ $sign_re and last;
# Simplistic quote avoidance may not work reliably with
# "format=flowed" Content-type.
$line =~ $quote_re and next;
push @body , $line;
}
scalar @body or exit;
for ( @body )
{
s/^\s+//;
s/\s+$//;
s/\s+/ /g;
}
my $body = join ' ' , @body;
print
length $body <= $max_char
? $body
: substr $body , 0 , $max_char
;
__END__
Oh, that generates an error:
procmail: Program failure (255) of " formail -I"" | grep -v "^>" |
/usr/bin/perl -e "$/ = undef; $_ = <>; s/\s+/ /sg; print substr
$_, 0, 200""
Does the above runs on Unix or Unix-like system? If so, change
double quotes around perl one-liner to single quotes.
(You should be aware that above various caveats apply when using
simplistic mail munging.)
--
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail