Paul,
You may want to check out CAP::Stream, which will handle file handling:
http://search.cpan.org/~purdy/CGI-Application-Plugin-Stream-2.10/lib/CGI/Application/Plugin/Stream.pm
It would reduce your runmode to this:
sub run_mode {
my $cgi_application = shift; # that's a long variable name ;)
my $very_huge_file = '/path/to/file';
if ( $cgi_application->stream_file( $very_huge_file ) ) {
return;
} else {
die "problem";
}
}
- Jason
Paul Miller wrote:
I'm trying to do something like this... it seems to work, but I'm
wondering if it'll backfire down the line.
sub run_mode {
my $cgi_application = shift;
my $cgi = $cgi_application->query;
open my $very_huge_file, "<", $filename or die [email protected]
print $cgi->header("application/octet-stream");
my $buf;
while( read $very_huge_file, $buf, 2048 ) {
print $buf;
}
exit 0;
}
##### CGI::Application community mailing list ################
## ##
## To unsubscribe, or change your message delivery options, ##
## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ##
## ##
## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ##
## Wiki: http://cgiapp.erlbaum.net/ ##
## ##
################################################################