#!/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;