jas@ISI.EDU (Jeff Sullivan) (02/28/91)
You realize that this code doesn't work.
The construct:
while (<STDIN>) {
if ($_ eq "\n") {$body = ""; }
elsif (! defined $body) {$header .= $_; }
else { $body .= $_; }
}
Will create a $body that is *local* to the block it's in; when it
exits the block, $body reverts to its (empty) value.
What you need is something like:
while (<STDIN>) {
if ($_ eq "\n") {$nowbody = ""; }
elsif (! defined $nowbody) {$header .= $_; }
else { $body .= $_; }
}
Where $nowbody is just a flag that tells you where to put the $_ being
read in. The defined state of the vaiable is preserved by perl.
jas