in reply to Sleep function

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);
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Sleep function
by programmercarlito (Novice) on Mar 15, 2015 at 22:03 UTC

    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.