my $filename = "/tmp/foo";
my $fh = Apache::gensym( ); # generate a new filehandle
open $fh, $filename or return NOT_FOUND;
print <$fh>;
close $fh;
it's better to write:
my $filename = "/tmp/foo";
my $fh = Apache::gensym( ); # generate a new filehandle
open $fh, $filename or return NOT_FOUND;
$r->send_fd($fh);
close $fh;
The former implementation uses more memory and it's
slower, because it creates a temporary variable to read the data in
and then print it out. The latter uses optimized C code to read the
file and send it to the client.
| | |
13.8. time( ) System Call Versus $r->request_time | | 13.10. Caching and Pre-Caching |