line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::IfModified; |
2
|
1
|
|
|
1
|
|
945
|
use 5.008001; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
45
|
|
4
|
1
|
|
|
1
|
|
18
|
use Exporter 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
337
|
|
5
|
|
|
|
|
|
|
our @EXPORT_OK = qw(if_modified touch vtouch vtouch_all); |
6
|
|
|
|
|
|
|
our $VERSION = qw(0.20); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %mtime; |
9
|
|
|
|
|
|
|
sub if_modified{ |
10
|
10
|
|
|
10
|
1
|
53424
|
my $file = shift; |
11
|
10
|
|
|
|
|
138
|
my $mtime = (stat $file)[9]; |
12
|
10
|
100
|
|
|
|
32
|
if ( defined $mtime ){ |
13
|
4
|
100
|
|
|
|
12
|
if ( exists $mtime{$file} ){ |
14
|
2
|
50
|
|
|
|
15
|
return if ( $mtime{$file} eq $mtime ); |
15
|
|
|
|
|
|
|
} |
16
|
2
|
|
|
|
|
6
|
$mtime{ $file } = $mtime; |
17
|
2
|
|
|
|
|
10
|
return 1; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
else { |
20
|
6
|
|
|
|
|
12
|
delete $mtime{$file}; |
21
|
6
|
|
|
|
|
55
|
return 1; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
sub touch{ |
25
|
2
|
|
|
2
|
1
|
5
|
my $file = shift; |
26
|
2
|
50
|
|
|
|
183
|
open my $fh, "+>", $file or die "touch: $file"; |
27
|
2
|
|
|
|
|
32
|
close $fh; |
28
|
2
|
|
|
|
|
9
|
delete $mtime{$file}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub vtouch{ |
32
|
1
|
|
|
1
|
1
|
3
|
delete $mtime{$_[0]}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
sub vtouch_all{ |
35
|
1
|
|
|
1
|
1
|
5
|
%mtime = (); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
__END__ |