in reply to how do I line-wrap while copying to stdout?
Thanks,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; } }
|
|---|