perplexing print problem 
Author Message
 perplexing print problem

Quote:

> Hi,
> I have this little test script.
> The problem is the script produces
> no output, unless a "\n" is added
> to the print statement.
> WHY?

the output is being buffered...set autoflush with this:
$| = 1;

--
robert sherman
css3, school of civil and environmental engineering
georgia institute of technology
atlanta, ga, usa



Mon, 17 May 2004 21:02:14 GMT  
 perplexing print problem

Quote:
> Hi,
> I have this little test script.
> The problem is the script produces
> no output, unless a "\n" is added
> to the print statement.

(snip)

You can use '$|++' to unbuffer STDOUT...

By default it gets flushed on newlines.

-Steve



Mon, 17 May 2004 21:07:31 GMT  
 perplexing print problem

Quote:

> Hi,
> I have this little test script.
> The problem is the script produces
> no output, unless a "\n" is added
> to the print statement.
> WHY?

Because of buffering.  To turn off STDOUT buffering, set $| to 1.
Or just use warn(), which is probably more appropriate.

--
After Spamtember comes Proctober.



Mon, 17 May 2004 21:05:58 GMT  
 perplexing print problem

Quote:

> On Thu, 29 Nov 2001 20:07:31 GMT, "Steve Grazzini"



> >> Hi,
> >> I have this little test script.
> >> The problem is the script produces
> >> no output, unless a "\n" is added
> >> to the print statement.
> >(snip)

> >You can use '$|++' to unbuffer STDOUT...

> >By default it gets flushed on newlines.

> Thanks. Now a followup question please.
> If perl flushes the buffer on a \n, how big can the print
> buffer get before it gives an error. Would it consume
> all available memory?

It doesn't "give an error."  When the buffer gets full, it gets printed
out.  When a newline appears in the data you have to print, the buffer
gets printed out.  If $| is 1, the data gets buffered, but the buffer
immediately gets printed out.  Only when the buffer is not full, and the
data you pass in via print() doesn't contain \n, does it not get
immediately printed.

--
Klein bottle for rent - inquire within.



Fri, 21 May 2004 10:39:13 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Perplexing problem

2. perplexing problem - bug in perl?, looking for suggestions

3. ? Now I am reaaly perplexed, Why doesn't (INDEX) work

4. Perplexed: Can't modify non-lvalue subroutine call

5. Perplexed....

6. perplexing DESTROY behavior

7. Perplexed: unreadable databases

8. Perplexed with newlines while sending mail

9. Perplexing pattern question

10. perplexing DESTROY behavior

11. Problem getting Perl to print (except when debug running)

12. Printing problems (works on Windows, not Linux...)

 

 
Powered by phpBB® Forum Software