#!/usr/bin/env perl # # bodyof - extract original text from message/posting # # $Id$ use warnings; use strict; sub bodyof_stdin { undef $/; foreach ( split /(^|\n)From .*\n/, ) { m#:.*\n\s*\n# and $_ = $'; # remove header m#^\s*([^:\n]+:\s*\n)?# and $_ = $'; # remove 'X said:' m#\n--# and $_ = $`; # remove sig s#(^|\n)[^\s\w].*##g; # remove quotations s#\s\s+$#\n#sm; # remove trailing whitespace s#^\s+##sm; # remove leading whitespace print $_, "\n"; } } if ( !@ARGV ) { &bodyof_stdin; } else { foreach my $F (@ARGV) { close(STDIN); if ( !open( STDIN, '<', $F ) ) { warn "cannot read $F, skipping it\n"; } else { &bodyof_stdin; } } }