line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Time::SoFar; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1410
|
use integer; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
4
|
|
5
|
1
|
|
|
1
|
|
26
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
476
|
|
6
|
|
|
|
|
|
|
$VERSION="1.00"; |
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@EXPORT_OK = qw( runtime runinterval figuretimes ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $lasttime; |
13
|
|
|
|
|
|
|
my $day; |
14
|
|
|
|
|
|
|
my $hour; |
15
|
|
|
|
|
|
|
my $min; |
16
|
|
|
|
|
|
|
my $sec; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub figuretimes($;$) { |
19
|
10
|
|
|
10
|
0
|
104
|
my $rtime = shift; |
20
|
10
|
|
|
|
|
16
|
my $noopt = shift; |
21
|
10
|
|
|
|
|
21
|
my @times; |
22
|
|
|
|
|
|
|
|
23
|
10
|
|
|
|
|
19
|
$min = $rtime / 60; # requires 'use integer' |
24
|
10
|
|
|
|
|
26
|
$sec = $rtime % 60; |
25
|
10
|
|
|
|
|
17
|
$hour = $min / 60; # requires 'use integer' |
26
|
10
|
|
|
|
|
16
|
$min = $min % 60; |
27
|
10
|
|
|
|
|
15
|
$day = $hour / 24; # requires 'use integer' |
28
|
10
|
|
|
|
|
15
|
$hour = $hour % 24; |
29
|
|
|
|
|
|
|
|
30
|
10
|
100
|
100
|
|
|
80
|
if ($day or $noopt) { |
|
|
100
|
|
|
|
|
|
31
|
4
|
|
|
|
|
23
|
@times = ($day, $hour, $min, $sec); |
32
|
|
|
|
|
|
|
} elsif ($hour) { |
33
|
1
|
|
|
|
|
5
|
@times = ($hour, $min, $sec); |
34
|
|
|
|
|
|
|
} else { |
35
|
5
|
|
|
|
|
15
|
@times = ($min, $sec); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
10
|
100
|
|
|
|
26
|
if (wantarray) { |
39
|
3
|
|
|
|
|
24
|
return @times; |
40
|
|
|
|
|
|
|
} else { |
41
|
7
|
|
|
|
|
42
|
my $return = join(':', @times); |
42
|
7
|
|
|
|
|
120
|
$return =~ s/:(\d)\b/:0$1/g; |
43
|
7
|
|
|
|
|
57
|
return $return; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} # end &figuretimes |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub runtime(;$) { |
48
|
2
|
|
|
2
|
0
|
87
|
my $noopt = shift; |
49
|
2
|
|
|
|
|
7
|
$lasttime = (time() - $^T); |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
9
|
return &figuretimes($lasttime, $noopt); |
52
|
|
|
|
|
|
|
} # end &runtime |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub runinterval(;$) { |
55
|
5
|
|
|
5
|
0
|
8001928
|
my $noopt = shift; |
56
|
5
|
100
|
|
|
|
35
|
if (!defined($lasttime)) { |
57
|
1
|
|
|
|
|
2
|
$lasttime = 0; |
58
|
|
|
|
|
|
|
} |
59
|
5
|
|
|
|
|
73
|
my $rtime = (time() - $^T); |
60
|
5
|
|
|
|
|
14
|
my $interval = $rtime - $lasttime; |
61
|
5
|
|
|
|
|
8
|
$lasttime = $rtime; |
62
|
|
|
|
|
|
|
|
63
|
5
|
|
|
|
|
17
|
return &figuretimes($interval, $noopt); |
64
|
|
|
|
|
|
|
} # end &runinterval |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |