-2

Hi I would like to implement and display a stopwatch timer in milliseconds using Perl.

Say I would like in this format HH:MIN:SECS:MILLISECS in Windows XP.

I tried by using Perl TK. I have a start and stop button. When I press the start button the stop watch timer should start and display in the above format. And by pressing the stop button it has to stop.

I searched some sample codes from Google but I am not getting in millisecs format:
(3 digit resolution) ie 1:23:45:678

Can anyone please help me.

4

1 に答える 1

2

Here is a partial solution to your problem - Stopwatch using TK - http://www.perlmonks.org/?node_id=897958

The annexed code (unfortunately untested) will help you display time in your desired format.

use strict;
use warnings;

use Time::HiRes qw(gettimeofday tv_interval usleep); 

my ($hrs, $mins, $secs, $mils) = (0, 0, 0, 0);

for my $h (0..23) {
    for my $m (0..59) {
        for my $s (0..59) {
            for my $ms (0..999) {
                print "$h:$m:$s:$ms\n";
                usleep(1000);
                $ms += 0.001;
            }
        }
    }
}
于 2012-06-05T20:07:18.600 に答える