You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by John ORourke <jo...@o-rourke.org> on 2008/05/21 23:03:20 UTC

Re: [OT] is there a maximum output character length ?

>> Well thanks!  Under regular CGI, every time your browser requests a page,
>> Apache has to find your script, load Perl, compile your script and any
>> modules you use, run it, and exit Perl.  Under mod_perl, all the loading and
>> compiling is done when Apache starts, not on every request - it's doing far
>> less work.  There's a lot of good info on http://perl.apache.org/ but I know
>> what it's like when you're too busy debugging to RTFM :)
>>
>>     
>
> Yeah, I have read a lot of those things that you wrote many times in
> peal.apache.org but I just don't know what is the specific relation to
> why it never write the file completely !
>   

It's just how operating systems work - to speed things up, when you 
write to the file you're actually writing to a buffer in memory.  When 
the buffer gets full (usually a few kB), the operating system will write 
it all out to the disk.  If you close the file, it will also write it 
all out the disk.  It's simply good practice to tidy up before you quit 
your program - previously you were relying on perl to do this for you, 
because it's good like that.

cheers
John

@ list, ! $| ;)
-- 


Re: [OT] is there a maximum output character length ?

Posted by Dodger <el...@gmail.com>.
If you have a reason to leave it open, you can always set autoflush on the file.

open FO, ">file_out";
my $was = select FO;
local $| = 1;
select $was;
print FO "a";
print FO "b";

etc.


2008/5/21 John ORourke <jo...@o-rourke.org>:
>
> Well thanks!  Under regular CGI, every time your browser requests a page,
> Apache has to find your script, load Perl, compile your script and any
> modules you use, run it, and exit Perl.  Under mod_perl, all the loading and
> compiling is done when Apache starts, not on every request - it's doing far
> less work.  There's a lot of good info on http://perl.apache.org/ but I know
> what it's like when you're too busy debugging to RTFM :)
>
>
>
> Yeah, I have read a lot of those things that you wrote many times in
> peal.apache.org but I just don't know what is the specific relation to
> why it never write the file completely !
>
>
> It's just how operating systems work - to speed things up, when you write to
> the file you're actually writing to a buffer in memory.  When the buffer
> gets full (usually a few kB), the operating system will write it all out to
> the disk.  If you close the file, it will also write it all out the disk.
> It's simply good practice to tidy up before you quit your program -
> previously you were relying on perl to do this for you, because it's good
> like that.
>
> cheers
> John
>
> @ list, ! $| ;)
> --
>
>



-- 
Dodger