is there a maximum output character length ?

is there a maximum output character length ?

am 21.05.2008 22:14:55 von Keenlearner

Hello, I am just so tired after hours of debugging, why does is never
write text into the file completely ? It has not problem if using CGI.

Let's say if I have
$ruleStr = "aaaaaaaaaaaaaa eeeeeeeeeeeeeee";

open(PARSER,">$self->{parser}.pm");
print PARSER $ruleStr;


It will write a few characters only, not complete. Is there a thread
problem or something ?
Thanks

Re: is there a maximum output character length ?

am 21.05.2008 22:30:15 von John ORourke

william wrote:
> Let's say if I have
> $ruleStr = "aaaaaaaaaaaaaa eeeeeeeeeeeeeee";
>
> open(PARSER,">$self->{parser}.pm");
> print PARSER $ruleStr;
>
> It will write a few characters only, not complete. Is there a thread
> problem or something ?
>

You need to explicitly close the file - under CGI, your program exits at
the end of the request and will close any open files. Under mod_perl it
will leave the files open.

Add close(PARSER) after you finish writing the file - this isn't a
mod_perl thing, it's just good programming practice.

John

Re: is there a maximum output character length ?

am 21.05.2008 22:41:43 von Keenlearner

On Thu, May 22, 2008 at 4:30 AM, John ORourke wrote:
> william wrote:
>>
>> Let's say if I have
>> $ruleStr = "aaaaaaaaaaaaaa eeeeeeeeeeeeeee";
>>
>> open(PARSER,">$self->{parser}.pm");
>> print PARSER $ruleStr;
>>
>> It will write a few characters only, not complete. Is there a thread
>> problem or something ?
>>
>
> You need to explicitly close the file - under CGI, your program exits at the
> end of the request and will close any open files. Under mod_perl it will
> leave the files open.
>
> Add close(PARSER) after you finish writing the file - this isn't a
> mod_perl thing, it's just good programming practice.
>
> John
>
>


Omg, I love you John, lol. Haha, I had spent at lease 3 hours for
this, why is it so in mod_perl ?

Thanks.

Re: is there a maximum output character length ?

am 21.05.2008 22:50:06 von John ORourke

This is a multi-part message in MIME format.
--------------010804080503090505070102
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

william wrote:
> On Thu, May 22, 2008 at 4:30 AM, John ORourke wrote:
>
>> william wrote:
>>
>>> It will write a few characters only, not complete. Is there a thread
>>> problem or something ?
>>>
>> You need to explicitly close the file - under CGI, your program exits at the
>> end of the request and will close any open files. Under mod_perl it will
>> leave the files open.
>>
> Omg, I love you John, lol. Haha, I had spent at lease 3 hours for
> this, why is it so in mod_perl ?
>

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 :)

John


--------------010804080503090505070102
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit







william wrote:
cite="mid:b4a0c4930805211341r202d66cta3090651947bc74@mail.gm ail.com"
type="cite">

On Thu, May 22, 2008 at 4:30 AM, John ORourke  wrote:


william wrote:



It will write a few characters only, not complete. Is there a thread
problem or something ?


You need to explicitly close the file - under CGI, your program exits at the
end of the request and will close any open files. Under mod_perl it will
leave the files open.


Omg, I love you John, lol. Haha, I had spent at lease 3 hours for
this, why is it so in mod_perl ?




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
but I know what it's like when you're too busy
debugging to RTFM :)



John






--------------010804080503090505070102--

Re: is there a maximum output character length ?

am 21.05.2008 22:54:15 von Keenlearner

On Thu, May 22, 2008 at 4:50 AM, John ORourke wrote:
> william wrote:
>
> On Thu, May 22, 2008 at 4:30 AM, John ORourke
> wrote:
>
>
> william wrote:
>
>
> It will write a few characters only, not complete. Is there a thread
> problem or something ?
>
>
> You need to explicitly close the file - under CGI, your program exits at the
> end of the request and will close any open files. Under mod_perl it will
> leave the files open.
>
>
> Omg, I love you John, lol. Haha, I had spent at lease 3 hours for
> this, why is it so in mod_perl ?
>
>
> 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 :)
>
> John
>
>

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 !
Thanks.

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

am 21.05.2008 23:03:20 von John ORourke

This is a multi-part message in MIME format.
--------------080105060102010003040302
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


>> 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, ! $| ;)
--


--------------080105060102010003040302
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit









cite="mid:b4a0c4930805211354l6ec4f5fx271f19e1d9e17c93@mail.g mail.com"
type="cite">



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 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, ! $| ;)

--






--------------080105060102010003040302--

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

am 22.05.2008 02:05:05 von el.dodgero

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 :
>
> 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