[cgiapp] very huge file modes
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 $!cgi...@lists.erlbaum.net print $cgi-header(application/octet-stream); my $buf; while( read $very_huge_file, $buf, 2048 ) { print $buf; } exit 0; } -- If riding in an airplane is flying, then riding in a boat is swimming. 110 jumps, 45.0 minutes of freefall, 86.2 freefall miles. # 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/ ## ####
Re: [cgiapp] very huge file modes
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 $!cgi...@lists.erlbaum.net 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/ ## ####
Re: [cgiapp] very huge file modes
On Mon, Jul 13, 2009 at 8:27 AM, Jason Purdyja...@journalistic.com wrote: 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 I'm definitely going to use this plugin, no question. ... but you're saying that what I'm doing will indeed work, it's just better written with CAP::Stream? -- If riding in an airplane is flying, then riding in a boat is swimming. 110 jumps, 45.0 minutes of freefall, 86.2 freefall miles. # 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/ ## ####
Re: [cgiapp] very huge file modes
Paul Miller wrote: ... but you're saying that what I'm doing will indeed work, it's just better written with CAP::Stream? You were using the correct idiom for dealing with large files. Don't read it all in memory at once, but instead chunk it. -- Michael Peters Plus Three, LP # 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/ ## ####