in reply to sleep in infinite loop

Flush the output:

#!/usr/bin/perl use warnings; use strict; $| = 1; while (1) { sleep 5; print "interval"; }

Replies are listed 'Best First'.
Re^2: sleep in infinite loop
by dsheroh (Monsignor) on Mar 13, 2008 at 14:45 UTC
    Ending the line will also force it to display immediately, so print "interval\n" will fix this. It's also probably what the OP actually meant to do, unless he wanted to see "intervalintervalinterval..." all the way across the screen.
Re^2: sleep in infinite loop
by Anonymous Monk on Mar 16, 2011 at 12:35 UTC
    you are my GOD !!!! I've been trying to do this for two weeks.. Thanks mate.. By the way what does this "flush" thing do and how it helps in rectifying the problem?? Thanks Shamal