in reply to how do I line-wrap while copying to stdout?

Thank you all for your comments. Using many suggestions from various responces, this is what the code looks like now, and it works great!

sub display_email { my ($fn) = @_; print "<center>file <i>$fn</i></center>\n"; if ( open EMAIL, $fn ) { print "<hr width=600><br>\n<pre>"; $/ = ''; $header = <EMAIL>; # slurp entire mail header in $header =~ s/\n\s+/ /g; # merge continuation lines foreach $_ ( split "\n", $header ) { print "$_\n" unless ( /^Message-Id:/ || /^Content[-\w]*:/ || /^X-[-\w]*:/ || /^Status: RO/ || /^Received:/ || /^Mime-Version:/ ); } # end of headers, now read and display the body of the email $/ = "\n"; print "\n"; while( <EMAIL> ) { chomp; # print lines of the file, line-wrapping at column 80 while ( length($_) > 80 ) { print substr( $_, 0, 80 ), "\n"; $_ = substr( $_, 80 ); } print "$_\n"; } print "</pre>\n"; close EMAIL; } }
Thanks,
-allan