Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Please, Help on I/O

5 views
Skip to first unread message

Christian Aperghis-Tramoni

unread,
Nov 4, 2004, 5:53:45 AM11/4/04
to perl6-i...@perl.org
I have the folowing program :

print "Give me an integer number : ¥n"
getstdin P0
readline S1,P0

Its execution gives :

10
Give me an integer number :

How is it possible to flush stdout before reading the number.

It means the equivalent of the $| in Perl.
______________________________________________________________________
\|||/
(o o)
+--ooO-( )-Ooo------------------------------------------+
| Christian Aperghis-Tramoni |
| |
| Case Postale 901 Tel : (33) 04 91 82 92 49 |
| 163 Avenue de Luminy SFR : (33) 06 18 93 10 70 |
| 13288 Marseille Cedex 09 Fax : (33) 04 91 82 92 75 |
| France Mel : ch...@dil.univ-mrs.fr |
/) ch...@aperghis.net (\
/ ) WEB : http://www.dil.univ-mrs.fr/~chris ( \
( (+-------------------------------------------------------+) )
((\ \) / ) / ) (/ //)
(\\\ \_/ / \ \_/ ///)
\ / \ /
___\___/__________________________________________________\___/________
print join('',map({$i=1-$i;$a=$i?10*$_."\b\b":pack"c",$a+$_+0x16}split
(//,"5110789279758710838810587992861093898779948387799310")),"...\n");
_______________________________________________________________________

Marty Pauley

unread,
Nov 4, 2004, 6:35:12 AM11/4/04
to perl6-i...@perl.org
On Thu Nov 4 11:53:45 2004, Christian Aperghis-Tramoni wrote:
>
> It means the equivalent of the $| in Perl.

You can switch off buffering on stdout by doing:

getstdout P1
pioctl I0, P1, 3, 0

To switch back to line buffering, do:

getstdout P1
pioctl I0, P1, 3, 1

--
Marty

Luke Palmer

unread,
Nov 4, 2004, 12:55:36 PM11/4/04
to Christian Aperghis-Tramoni, perl6-i...@perl.org
Christian Aperghis-Tramoni writes:
> I have the folowing program :
>
> print "Give me an integer number : ¥n"
> getstdin P0
> readline S1,P0
>
> Its execution gives :
>
> 10
> Give me an integer number :
>
> How is it possible to flush stdout before reading the number.
>
> It means the equivalent of the $| in Perl.

No, it doesn't quite. As in C++'s iostreams, streams ought to have the
ability to be "tied". That is, a call on one automatically flushes the
other. stdout should be tied to stdin this way.

Luke

0 new messages