#!/usr/bin/perl -s use Win32; $inbox = 'D:\My Documents\Netscape\Users\martian\Mail\Inbox'; $paperback = 'C:\Program Files\Paprbk20.exe'; $textfile = 'T:\DaveNet.txt'; $sender = "DaveNet"; $linecount = $msgcount = 0; @msg = (); $isdavenet = 0; $accumulate = 0; open(fin, $inbox); open(fout, ">" . $textfile); while() { $linecount++; if( m/^From - .*/ ) { print "."; if(@msg && $isdavenet) { $msglen = @msg; $isdavenet = 0; print fout "$subject"; print fout "$date"; @msg = &format_text(@msg); foreach $line (@msg) { print fout "$line\n"; } print fout "\n--------------------------------------------------\n\n"; } @msg = (); $isdavenet = 0; $accumulate = 0; $msgcount++; } else { if( m/^From: .*$/ ) { if( m/^From:.*$sender.*$/ ) { $isdavenet = 1; } } } if( m/^Subject:/ && !$accumulate) { $subject = $_; } if( m/^Date:/ && !$accumulate) { $date = $_; } if( !$accumulate && ($_ eq "\n") && $isdavenet) { $accumulate = 1; } if($accumulate) { $_ =~ s/\n//g ; @msg = (@msg, $_); } } print "."; if(@msg && $isdavenet) { $msglen = @msg; $isdavenet = 0; print fout "$subject"; print fout "$date"; @msg = &format_text(@msg); foreach $line (@msg) { print fout "$line\n"; } print fout "\n--------------------------------------------------\n\n"; } @msg = (); $isdavenet = 0; $accumulate = 0; $msgcount++; print "\nlines: $linecount\nmessages: $msgcount\n"; close(fin); close(fout); Win32::Spawn($paperback, $paperback . " " . $textfile, $pid); sub format_text { local(@orig) = @_; local(@result) = (); local($para) = ""; foreach (@orig) { if(m/^ .+/) { if($para) { $_ =~ s/ *(.*) */$1/ ; $para = $para . " " . $_ ; } else { if(m/^ .*/) { $_ =~ s/ *(.*) */$1/ ; $para = " " . $_ ; } else { $para = $_; } } } else { if($para) { @result = (@result, $para); $para = ""; } @result = (@result, $_); } } while( $result[$#result] eq "" ) { pop(@result); } return @result; }