programmercarlito has asked for the wisdom of the Perl Monks concerning the following question:

Hi there to all Is there a way to see the sleep function counting. I know its counting down in the background. Is it possible to see it. like it would output each number on the screen per second. Thanks

Replies are listed 'Best First'.
Re: Sleep function
by choroba (Cardinal) on Mar 15, 2015 at 21:34 UTC
    sleep is often implemented by alarm, not by counting down. You can implement your own sleep that would count down, though. The naive implementation might be a bit imprecise:
    sub mysleep { my $seconds = shift; while ($seconds) { print $seconds--, "\n"; sleep 1; } } mysleep(5);
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      I want it to work something like this. I tried with a while loop but it just doesnt seem to work that way.

      $num = 1; sleep($num); print "1\n"; sleep($num); print "2\n"; sleep($num); print "3\n"; system("pause");
        Never mind I got it to work. I used the != in while and it worked perfectly.