Re: More Info About $| = 1;

2006-10-19 Thread Derek B. Smith
--- Andreas Puerzer <[EMAIL PROTECTED]> wrote:

> Derek B. Smith schrieb:
> 
> > -- Andreas Puerzer <[EMAIL PROTECTED]> wrote:
> > 
> 
> [snipped for brevity]
> 
> >>
> >>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
> > 
> 
> Ok, done so. Now I understand about
> line-buffering-mode (what I didn't
> before, but, as I also said, I hadn't investigated
> further), thank you.
> I still think that the only way to cope with this is
> to set $| to a true
> value, or do you have another idea?
> 
> Kind Greetings,
> 
> Andreas Puerzer
> 

Not really, but if you want you could create a
subroutine that contains:
and call it whenver you need to.

sub HFH {
local $ofh = select LOG;
$| = 1; 
select $ofh;
}


__
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]
 




Re: More Info About $| = 1;

2006-10-19 Thread Andreas Puerzer
Derek B. Smith schrieb:

> -- Andreas Puerzer <[EMAIL PROTECTED]> wrote:
> 

[snipped for brevity]

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

Ok, done so. Now I understand about line-buffering-mode (what I didn't
before, but, as I also said, I hadn't investigated further), thank you.
I still think that the only way to cope with this is to set $| to a true
value, or do you have another idea?

Kind Greetings,

Andreas Puerzer

-- 
perl -mAcme::JAPH

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




Re: More Info About $| = 1;

2006-10-19 Thread Chris Share

Thanks to all who responded.

The "Suffering from Buffering?" article explains everything.

Cheers,

Chris

Derek B. Smith wrote:


--- "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]
 




Re: More Info About $| = 1;

2006-10-19 Thread Derek B. Smith


--- "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]
 




Re: More Info About $| = 1;

2006-10-19 Thread Derek B. Smith
-- 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


__
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]
 




Re: More Info About $| = 1;

2006-10-19 Thread Andreas Puerzer
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.

Kind greetings,

Andreas Puerzer

-- 
perl -mAcme::JAPH

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




RE: More Info About $| = 1;

2006-10-18 Thread bou, hou \(GE Money, consultant\)
I am using EPIC too. But when I open the *.pm file with utf-8 , eclipse always 
show out of system
virtual memory error,and then I have to shut down the eclipse. who can tell me 
why?

-Original Message-
From: Chris Share [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 19, 2006 7:54 AM
To: beginners@perl.org
Subject: More Info About $| = 1;


Hi,

I'm a C programmer teaching myself Perl. I'm working on Windows XP using
ActivePerl and Eclipse (EPIC).

I've got a question about $| = 1;

If I run the following program:

#!/usr/local/bin/perl

use strict;
use warnings;

print "What is your name? ";
my $name = ;
chomp $name;
print "Hello, $name!\n";

the command line does nothing until I enter some text, at which point
the program runs and outputs the following:

Test
What is your name? Hello, Test!

What I don't get is why the print statement doesn't execute?

If I add $| = 1; at the top of the program this fixes the problem and
the program runs as expected.

Could someone explain what's going on here, or point me to an explanation.

Cheers,

Chris


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



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




Re: More Info About $| = 1;

2006-10-18 Thread John W. Krahn
Chris Share wrote:
> Hi,

Hello,

> I'm a C programmer teaching myself Perl. I'm working on Windows XP using
> ActivePerl and Eclipse (EPIC).
> 
> I've got a question about $| = 1;
> 
> If I run the following program:
> 
> #!/usr/local/bin/perl
> 
> use strict;
> use warnings;
> 
> print "What is your name? ";
> my $name = ;
> chomp $name;
> print "Hello, $name!\n";
> 
> the command line does nothing until I enter some text, at which point
> the program runs and outputs the following:
> 
> Test
> What is your name? Hello, Test!
> 
> What I don't get is why the print statement doesn't execute?
> 
> If I add $| = 1; at the top of the program this fixes the problem and
> the program runs as expected.
> 
> Could someone explain what's going on here, or point me to an explanation.

Read MJD's arcticle "Suffering from Buffering?" at
http://perl.plover.com/FAQs/Buffering.html


John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

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




Re: More Info About $| = 1;

2006-10-18 Thread Tom Phoenix

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.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




Re: More Info About $| = 1;

2006-10-18 Thread Omega -1911

Hi,

I'm a C programmer teaching myself Perl. I'm working on Windows XP using
ActivePerl and Eclipse (EPIC).

I've got a question about $| = 1;



Hello to you as well.

 To answer your question from above, the $| = 1; is
simply a method to prevent Perl from buffering and to go ahead and
output data. 

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




RE: More Info About $| = 1;

2006-10-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 
I copied and ran without the $|=1 and it displays the text What
is your name? and I enter na d it completes.

I tried both from the cmd.exe and a kornshell and both wroked
the same way.

Might it have something to do with Eclipse?

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Chris Share [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 18, 2006 15:54
To: beginners@perl.org
Subject: More Info About $| = 1;

Hi,

I'm a C programmer teaching myself Perl. I'm working on Windows XP using
ActivePerl and Eclipse (EPIC).

I've got a question about $| = 1;

If I run the following program:

#!/usr/local/bin/perl

use strict;
use warnings;

print "What is your name? ";
my $name = ;
chomp $name;
print "Hello, $name!\n";

the command line does nothing until I enter some text, at which point
the program runs and outputs the following:

Test
What is your name? Hello, Test!

What I don't get is why the print statement doesn't execute?

If I add $| = 1; at the top of the program this fixes the problem and
the program runs as expected.

Could someone explain what's going on here, or point me to an
explanation.

Cheers,

Chris


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




**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


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