line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Email::Delete::Mbox; |
2
|
|
|
|
|
|
|
# $Id: Mbox.pm,v 1.3 2004/12/17 18:45:50 cwest Exp $ |
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
64
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
package Email::LocalDelivery::OverwriteMbox; |
7
|
1
|
|
|
1
|
|
6
|
use base qw[Email::LocalDelivery::Mbox]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
196
|
|
8
|
|
|
|
|
|
|
my $fh; |
9
|
6
|
|
|
6
|
|
9
|
sub _set_fh { $fh = $_[1] } |
10
|
2
|
|
|
2
|
|
485
|
sub _open_fh { $fh } |
11
|
2
|
|
|
2
|
|
593
|
sub _close_fh { 1 } |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package Email::Delete::Mbox; |
15
|
1
|
|
|
1
|
|
6
|
use base qw[Email::Folder::Mbox]; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1030
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
16612
|
use vars qw[$VERSION]; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
18
|
|
|
|
|
|
|
$VERSION = '2.002'; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
973
|
use Email::Folder; |
|
1
|
|
|
|
|
693
|
|
|
1
|
|
|
|
|
33
|
|
21
|
1
|
|
|
1
|
|
8
|
use IO::File; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
541
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub delete_message { |
24
|
3
|
|
|
3
|
0
|
16
|
my %args = @_; |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
30
|
my $fh = IO::File->new($args{from}, '+<'); |
27
|
3
|
|
|
|
|
419
|
flock $fh, 2; |
28
|
|
|
|
|
|
|
{ |
29
|
3
|
|
|
|
|
6
|
local $^W = 0; |
|
3
|
|
|
|
|
18
|
|
30
|
3
|
|
|
3
|
|
34
|
*_get_fh = sub { $fh }; |
|
3
|
|
|
|
|
190
|
|
31
|
|
|
|
|
|
|
} |
32
|
3
|
|
|
|
|
26
|
my $folder = Email::Folder->new( |
33
|
|
|
|
|
|
|
$args{from}, |
34
|
|
|
|
|
|
|
reader => __PACKAGE__, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
320
|
my (@keep, @delete); |
38
|
3
|
|
|
|
|
15
|
while ( my $message = $folder->next_message ) { |
39
|
7
|
|
|
|
|
1667
|
my $trash_it = $args{matching}->($message); |
40
|
7
|
100
|
|
|
|
201
|
if ( $trash_it ) { |
41
|
5
|
|
|
|
|
10
|
push @delete, $message; |
42
|
5
|
|
|
|
|
20
|
next; |
43
|
|
|
|
|
|
|
} |
44
|
2
|
|
|
|
|
11
|
push @keep, $message; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
3
|
50
|
|
|
|
91
|
return 0 unless @delete; |
48
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
20
|
seek $fh, 0, 0; |
50
|
3
|
|
|
|
|
25
|
Email::LocalDelivery::OverwriteMbox->_set_fh($fh); |
51
|
|
|
|
|
|
|
Email::LocalDelivery::OverwriteMbox->deliver($_->as_string, $fh) |
52
|
3
|
|
|
|
|
18
|
for @keep; |
53
|
3
|
|
|
|
|
33
|
Email::LocalDelivery::OverwriteMbox->_set_fh(undef); |
54
|
3
|
|
|
|
|
268
|
truncate $fh, tell $fh; |
55
|
3
|
|
|
|
|
48
|
close $fh; |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
72
|
return scalar @delete; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |