[HRPM] an actual question!
Mike Patten
mike.patten2 at verizon.net
Thu May 23 17:56:40 CDT 2002
Troy E. Webster wrote:
>All,
>
>Given an email written to disk, I need a small perl driver that strips
>off the header information and writes the message back out to disk( minus
>the header ). Anyone have a clean method for this using
>out-of-the-box perl (without any extra CPAN modules)? I'm writing my own
>of course, but I'd like to see other examples in case I miss
>something. Been a long while since I've written any perl ...
>
>Thanks,
>
>
If I'm not mistaken, there are no blank lines in the header and a blank
line separates the header from the body. Assuming that's the case and
that the file only contains one piece of e-mail, this should read the
file from STDIN or a file specified on the command line and print the
body of the message to STDOUT.
#!/usr/bin/perl -w
use strict;
my $body = 0;
while (<>) {
if ($body) {
print;
} elsif ( m/^\s*$/ ) { # if the line contains nothing except
(maybe) whitespace,
$body = 1; # the body comes next
}
}
--
"...very few phenomena can pull someone out of Deep Hack Mode, with two
noted exceptions: being struck by lightning, or worse, your *computer*
being struck by lightning."
(By Matt Welsh)
Mike Patten <mike.patten2 at verizon.net>
More information about the Norfolk-pm
mailing list