#!/usr/bin/perl use strict; use CGI; use Digest::SHA1; use URI::Escape; use Tetragon; my $q = new CGI; print Tetragon::html_header(); print <Converting an MS Word File

This web-based program is designed to convert a fiction manuscript from MS Word format to plain text format. The main advantage of this over a simple "Save as" in Word is that it will automatically format italics _like this_ and boldface *like this*. Once you upload your file, the resulting converted version will be displayed in your browser, and you can cut and paste it into a text editor such as NotePad.

Caveats:

STUFF print <

file:

STUFF print Tetragon::html_footer(); #### #!/usr/bin/perl use strict; use CGI; use Digest::SHA1; use Tetragon; use IO::File; use POSIX; use constant UPLOAD_DIR => "/usr/local/www/tetragonsf/uploads"; # not clear to me that this actually has any effect use constant BUFFER_SIZE => 16_384; use constant MAX_FILE_SIZE => 2_000_000; use constant MAX_DIR_SIZE => 500_000_000; use constant MAX_OPEN_TRIES => 100; $CGI::DISABLE_UPLOADS = 0; $CGI::POST_MAX = MAX_FILE_SIZE; my $q = new CGI; print <<'HEADER'; Content-type: text/plain HEADER my $filename = $q->param('foo'); my $fh = $q->upload('foo'); my $buffer = ''; my $t = ''; binmode $fh; while (read($fh,$buffer,BUFFER_SIZE)) { $t = $t . $buffer; } my $in; do {$in = POSIX::tmpnam()} until ! -e $in; my $out; do {$out = POSIX::tmpnam()} until ! -e $out; open(F,">$in") or die "error opening temporary file for doc"; binmode F; print F $t; close F; system("/home/bcrowell/Documents/programming/scripts/fiction_word_to_txt <$in >$out")==0 or die "error executing fiction_word_to_txt"; local $/; # slurp whole file open(F,"<$out") or die "error reading output of fiction_word_to_txt"; my $txt = ; close F; unlink $in; unlink $out; print $txt;