in reply to How do I pause real time in Perl
Run this (it's --mostly-- not a 'how-to' but rather an illustration of 'how-not-to-do-it.'); chew on what you see as output for a bit:
(mostly) BAAAD CODE! #!/usr/bin/perl use 5.016; # implicit use strict; with recent vers +ions of perl use warnings; # 1060823 my $countdown = 1*60; # 60 seconds $| = 1; # disable output buffering my $start_time = time; # use the time function (see perldoc - +f time) say "\t \$start_time: $start_time"; my $end_time = $start_time + $countdown; for (;;) { # empty for clause my $time = time; say $time; last if ($time >= $end_time); # printf("\r%02d:%02d:%02d", ($end_time - $time) / (1*60); ($end_t +ime - $time) / 60%60, ($end_time - $time) % 60); say "Ln 19: " . (($end_time - $time) / (1*60)); say " Ln 20: " . (($end_time - $time) / 60%60); say " Ln 23: " .(($end_time - $time) % 60); sleep(1); }
Questions? C'mon back with those you can't answer for yourself from the relevant documents, Tutorials here, etc. You'll get quick and friendly responses.
|
|---|