--- "Derek B. Smith" <[EMAIL PROTECTED]>
wrote:

> -- Andreas Puerzer <[EMAIL PROTECTED]> wrote:
> 
> > Tom Phoenix schrieb:
> > > On 10/18/06, Chris Share <[EMAIL PROTECTED]>
> > wrote:
> > > 
> > >> I've got a question about $| = 1;
> > > 
> > > ....
> > > 
> > >> If I add $| = 1; at the top of the program this
> > fixes the problem and
> > >> the program runs as expected.
> > > 
> > > 
> > > Normally, output is buffered for efficiency;
> > instead of writing each
> > > byte at once, output is saved in a buffer. The
> > buffer is automatically
> > > flushed under various circumstances, such as
> > end-of-program, or when
> > > the buffer gets full. Setting $| to 1 flushes
> the
> > buffer after each
> > > print or printf statement, as you found, so it's
> > much like having no
> > > buffer at all.
> > > 
> > > Usually the buffer is flushed whenever the
> program
> > stops to read
> > > input; your system seems to be an exception.
> > Perhaps your perl binary
> > > is misconfigured? Or maybe you have a non-Unix
> > system that does I/O
> > > differently than most. But what you describe
> isn't
> > quite the
> > > documented behavior.
> > > 
> > 
> > It's not the documented behavior when running from
> > the CLI, but the OP
> > wrote:
> > 
> > Chris Share:
> > > Hi,
> > >
> > > I'm a C programmer teaching myself Perl. I'm
> > working on Windows XP using
> > > ActivePerl and Eclipse (EPIC).
> > 
> > I've seen this with so many Editors (no, better:
> > IDE's), it's definitely
> > not a Perl issue, but, in this case, a Eclipse
> > issue. I havn't dug too
> > far into this, but each IDE (that I know  of) that
> > offers to run perl
> > inside its own Console suffers from this problem:
> > there seems to be
> > another layer of buffering going on (Eclipse calls
> > this: 'Allocate
> > Console') that makes it necessary to autoflush.
> > 
> > So, to the OP, if  you want to take input from
> your
> > program when run
> > inside Eclipse, you will need to fiddle with $|,
> due
> > to that
> > extra-buffering-layer. If you run it outside
> > Eclipse, there shouldn't be
> > a need to do so.
> 
> Please review the online document for a clear
> explanation of $|.
> 
> http://perl.plover.com/FAQs/Buffering.html
> 


I am running Eclipse and I also am seeing what u are
seeing.  

Eclipse SDK

Version: 3.2.1
Build id: M20060921-0945

The only fix I can see is placing this variable in
your template if you have configured one.
Window->Preferences->Perl EPIC->Templates->edit
Then to apply this template type in the "keyword" you
saved it as then it cntl spacebar and Eclipse will
place it where your cursor is.



The key is in the reading I suggested above...here is
a snippet of why you are seeing this:

Where's the buffering? Why didn't Perl save up the
output until it had a full buffer? Because that's
almost never what you want when you're writing to a
terminal, the standard I/O library that Perl uses
takes care of it for you. When a filehandle is
attached to the terminal, as STDOUT is here, it is in
line buffered mode by default. A filehandle in line
buffered mode has two special properties: It's flushed
automatically whenever you print a newline character
to it, and it's flushed automatically whenever you
read from the terminal. The second property is at work
here: STDOUT is flushed automatically when we read
from STDIN. 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to