B
Babacio
Hi,
Sorry if the question looks stupid to some of you...
Here is a piece of code:
####################################
use Curses;
initscr();
# here I should use curses
endwin();
print "Hello!\n";
print "What do you say? ";
$x=<STDIN>;
print "You said $x\n";
#####################################
The functions initscr() and endwin() are to be use before and after
doing stuff with curses...
When I run it (on Mac OS X / darwin), I have the following problem :
the text of the three prints does not appear until the end of the
program, so I enter the value of $x with nothing printed, and
after that the three line appear.
This is due to some pertubation Curses makes in the terminal.
This second piece of code sort of give a solution to this problem:
####################################
use Curses;
use IO::Handle;
initscr();
# here I should use curses
endwin();
STDOUT->autoflush(1); # or $|=1
print "Hello!\n";
print "What do you say? ";
$x=<STDIN>;
print "\nYou said $x\n";
#####################################
Forcing STDOUT to flush contiuously, the behaviour is (seems to be)
what is expected.
But it is obvious that this in not the right way to solve the
problem. The vale of $| should remain 0.
Any idea?
Sorry if the question looks stupid to some of you...
Here is a piece of code:
####################################
use Curses;
initscr();
# here I should use curses
endwin();
print "Hello!\n";
print "What do you say? ";
$x=<STDIN>;
print "You said $x\n";
#####################################
The functions initscr() and endwin() are to be use before and after
doing stuff with curses...
When I run it (on Mac OS X / darwin), I have the following problem :
the text of the three prints does not appear until the end of the
program, so I enter the value of $x with nothing printed, and
after that the three line appear.
This is due to some pertubation Curses makes in the terminal.
This second piece of code sort of give a solution to this problem:
####################################
use Curses;
use IO::Handle;
initscr();
# here I should use curses
endwin();
STDOUT->autoflush(1); # or $|=1
print "Hello!\n";
print "What do you say? ";
$x=<STDIN>;
print "\nYou said $x\n";
#####################################
Forcing STDOUT to flush contiuously, the behaviour is (seems to be)
what is expected.
But it is obvious that this in not the right way to solve the
problem. The vale of $| should remain 0.
Any idea?