Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!linac!att!ucbvax!ISI.EDU!jas From: jas@ISI.EDU (Jeff Sullivan) Newsgroups: comp.mail.mh Subject: Re: Perl parsing mail headers Message-ID: <9102272324.AA00110@venera.isi.edu> Date: 27 Feb 91 23:25:37 GMT References: <9102262310.AA02095@coke.eng.umd.edu> Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: jas@isi.edu Organization: The Internet Lines: 32 You realize that this code doesn't work. The construct: while () { 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 () { 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