You learn a lot from looking at the low-level tracing. While looking at some problems with IO. I've traced the modules/cgiupload test and observed that it does too many read/write calls on a big file. So I've changed it to slurp the file at once and print it out in one go. While there were just a few read calls, to my surprise it still did many write calls as if it was printed line by line. Only after adding 'local $/' everything went in one write call. I wonder if it's a bug in PerlIO.

Index: t/response/TestModules/cgiupload.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestModules/cgiupload.pm,v
retrieving revision 1.2
diff -u -r1.2 cgiupload.pm
--- t/response/TestModules/cgiupload.pm 11 Apr 2002 11:08:45 -0000      1.2
+++ t/response/TestModules/cgiupload.pm 31 Oct 2003 21:00:06 -0000
@@ -13,11 +13,10 @@

my $cgi = CGI->new;

+    local $\;
+    local $/;
     my $file = $cgi->param('filename');
-
-    while (<$file>) {
-        print;
-    }
+    print <$file>;

     Apache::OK;
 }


__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to