| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Email::Delete; |
|
2
|
1
|
|
|
1
|
|
22767
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
35
|
|
|
3
|
|
|
|
|
|
|
## no critic RequireUseWarnings |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Email::Delete - Delete Messages from Folders |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
version 2.002 |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use base qw[Exporter]; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
148
|
|
|
16
|
1
|
|
|
1
|
|
6
|
use vars qw[@EXPORT_OK $VERSION]; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
95
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
@EXPORT_OK = qw[delete_message]; |
|
19
|
|
|
|
|
|
|
$VERSION = '2.002'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
798
|
use Email::FolderType qw[folder_type]; |
|
|
1
|
|
|
|
|
13221
|
|
|
|
1
|
|
|
|
|
196
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Email::Delete qw[delete_message]; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $message_id = shift @ARGV; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
delete_message from => $ENV{MAIL}, |
|
30
|
|
|
|
|
|
|
matching => sub { |
|
31
|
|
|
|
|
|
|
my $message = shift; |
|
32
|
|
|
|
|
|
|
$message->header('Message-ID') =~ $message_id; |
|
33
|
|
|
|
|
|
|
}; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This software will delete messages from a given folder if the |
|
38
|
|
|
|
|
|
|
test returns true. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 delete_message |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
delete_message from => 'folder_name', |
|
43
|
|
|
|
|
|
|
with => 'My::Delete::Package', |
|
44
|
|
|
|
|
|
|
matching => sub { return_true_for_delete() }; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
C is a required parameter, a string containing the folder |
|
47
|
|
|
|
|
|
|
name to delete from. By default C is used |
|
48
|
|
|
|
|
|
|
to determine what package to use when deleting a message. To |
|
49
|
|
|
|
|
|
|
override the default, specify the C parameter. Your |
|
50
|
|
|
|
|
|
|
package's C function will be called with the |
|
51
|
|
|
|
|
|
|
same arguments that C from Email::Delete is |
|
52
|
|
|
|
|
|
|
called with. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
C is a required argument. Its value is a code reference. |
|
55
|
|
|
|
|
|
|
If the anonymouse subroutine returns a true value, the current |
|
56
|
|
|
|
|
|
|
message is deleted. Each message is passed to the C |
|
57
|
|
|
|
|
|
|
test in turn. The first and only argument to C is |
|
58
|
|
|
|
|
|
|
an C object representing the message. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
If you should ever want to stop processing a mailbox, just call |
|
61
|
|
|
|
|
|
|
C from your code reference. A proper deleting package will |
|
62
|
|
|
|
|
|
|
not delete mail until all the messages have been scanned. So |
|
63
|
|
|
|
|
|
|
if you throw an exception, your mail will be preserved and scanning |
|
64
|
|
|
|
|
|
|
will be aborted. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub delete_message { |
|
69
|
4
|
|
|
4
|
1
|
79608
|
my %args = @_; |
|
70
|
4
|
|
|
|
|
10
|
my $with = $args{with}; |
|
71
|
4
|
50
|
|
|
|
22
|
unless ( $with ) { |
|
72
|
4
|
|
|
|
|
27
|
my $type = folder_type $args{from}; |
|
73
|
4
|
|
|
|
|
13396
|
$with = __PACKAGE__ . "::$type"; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
1
|
50
|
|
1
|
|
770
|
eval "use $with"; die if $@; |
|
|
1
|
|
|
1
|
|
3
|
|
|
|
1
|
|
|
1
|
|
20
|
|
|
|
1
|
|
|
1
|
|
704
|
|
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
27
|
|
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
18
|
|
|
|
1
|
|
|
|
|
12
|
|
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
16
|
|
|
|
4
|
|
|
|
|
324
|
|
|
|
4
|
|
|
|
|
25
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
4
|
|
|
|
|
53
|
$with->can('delete_message')->(%args); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L, |
|
86
|
|
|
|
|
|
|
L, |
|
87
|
|
|
|
|
|
|
L, |
|
88
|
|
|
|
|
|
|
L. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Casey West, >. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Copyright (c) 2004 Casey West. All rights reserved. |
|
97
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
|
98
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |