English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I tried to execute the following script:
print "Hello\n";
sleep 3;
print "Hi";

and what it does is: sleep for 3 seconds, and then print "hello hi" instead of printing "hello" sleep 3 seconds and then print "hi".
Anyone please help.

2006-09-21 23:31:23 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

NO I doubt that's the answer. I tried the same script on ActivePerl for windows and once again same result... help anyone...??

2006-09-22 06:33:56 · update #1

Although I agree that it might be that the output is shown after the script terminates. But the problem is I want the delay in the printing of statements.. Do you know how I can set it that way?

2006-09-22 06:36:09 · update #2

2 answers

Add a line to unbuffer the output:

$| = 1;

This should eliminate output buffering and cause things to be immediately output to the screen.

2006-09-22 10:46:58 · answer #1 · answered by LDude7 2 · 1 0

It is probably a problem in what you perceive to be happening.
What is the standard output set to for this program?

The program is probably doing exactly what you have asked it to do but the output is not released until the script terminates.

2006-09-22 08:28:05 · answer #2 · answered by AnalProgrammer 7 · 0 0

fedest.com, questions and answers