[ale] perl, *nix, or user error

John Wells jb at sourceillustrated.com
Wed Apr 3 11:59:22 EST 2002


Your output is most likely being buffered.

Setting $| = 1 should do it....


---------  Original message --------
From: Cade Thacker <linux at cade.org>
To: ale at ale.org
To: ale at ale.org <ale at ale.org>
Subject: [ale] perl, *nix, or user error
Date: 04-03-02 21:53

> Ok, I have tried this on FreeBSD, Linux, and HP-UX.  A very simple script
that I can not seem to make work the way I want.

********************* BEGINING OF SCRIPT ************************

#!/usr/bin/perl -w

print &quot;Hello World &quot;;

$counter = 0;
while ($counter &lt; 10)
{
print &quot;$counter &quot;;
$counter++;
sleep 1;
}

******************* END OF SCRIPT **********************

OK, I expect it to print Hello World, then 0-9 at 1 second intervals, all
on the same line, instead it prints it all out at once, 10 seconds after
starting the program.

It will print things out one at a time if I put a 'n' at the end of any
'print' lines, but I want the count on one line.

Can anyone help? Do I need to flush the buffer or something?

cade was here


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list