line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Topica::Reply; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
379
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=pod |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
WWW::Topica::Index - parse a single Topic mailing list index |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $index = WWW::Topic::Index->new($index_html); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
foreach my $message_id ($index->message_ids) { |
16
|
|
|
|
|
|
|
# the mail has some information and also provides a link to the reply ... |
17
|
|
|
|
|
|
|
my $mail = WWW::Topica::Mail->new($topica->fetch_mail($mess_id), $mess_id); |
18
|
|
|
|
|
|
|
# which has other information (like the un-htmled mail and the email address) ... |
19
|
|
|
|
|
|
|
my $reply = WWW::Topica::Reply->new($topica->fetch_reply($mail->id, $mail->eto), $mail->id, $mail->eto); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
print "Next offset is ".$index->next."\n"; |
23
|
|
|
|
|
|
|
print "Previous offset is ".$index->prev."\n"; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Used to parse a single reply page from Topica.com's mailing list indexes. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Reply pages have the body of the email (albeit quoted) and potentially a full email address. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 METHODS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 new |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Takes the html of the page, the eto and the message-id and parses the html. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
300
|
|
|
300
|
1
|
959
|
my ($class, $html, $id, $eto) = @_; |
45
|
|
|
|
|
|
|
|
46
|
300
|
|
|
|
|
3390
|
my $self = { id=>$id, eto=>$eto }; |
47
|
|
|
|
|
|
|
|
48
|
300
|
|
|
|
|
5050
|
bless $self, $class; |
49
|
|
|
|
|
|
|
|
50
|
300
|
|
|
|
|
1126
|
$self->parse($html); |
51
|
|
|
|
|
|
|
|
52
|
300
|
|
|
|
|
1270
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 parse |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Parse the html to get the subject, email address and body of the email. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub parse { |
63
|
300
|
|
|
300
|
1
|
714
|
my ($self,$html) = @_; |
64
|
|
|
|
|
|
|
|
65
|
300
|
|
|
|
|
14324
|
(undef, $self->{email}) = ($html =~ m!(.+?)!s); |
66
|
300
|
|
|
|
|
5863
|
($self->{subject}) = ($html =~ m!NAME\="subject" SIZE\=28 VALUE\="(.+?)"!s); |
67
|
300
|
|
|
|
|
4792
|
($self->{body}) = ($html =~ m!!s); |
68
|
|
|
|
|
|
|
|
69
|
300
|
50
|
|
|
|
1575
|
return unless $self->{body}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# the body is quoted as if ready to reply. So we need to clean that up. |
72
|
300
|
|
|
|
|
2957
|
$self->{body} =~ s!^(.+?) wrote:!!sg; |
73
|
300
|
|
|
|
|
6518
|
$self->{body} =~ s!^>\s?!!msg; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 id |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Get the message id |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub id { |
85
|
300
|
|
|
300
|
1
|
1517
|
return $_[0]->{id}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 eto |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Get the message eto |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub eto { |
95
|
300
|
|
|
300
|
1
|
1009
|
return $_[0]->{eto}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 email |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Get the email address parsed out. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub email { |
105
|
300
|
|
50
|
300
|
1
|
1367
|
my $email = $_[0]->{email} || ""; |
106
|
|
|
|
|
|
|
|
107
|
300
|
|
|
|
|
2182
|
return $email; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 subject |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Get the email subject parsed out. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub subject { |
118
|
0
|
|
0
|
0
|
1
|
0
|
my $subject = $_[0]->{subject} || ""; |
119
|
0
|
|
|
|
|
0
|
return $subject; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 body |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Get the email body parsed out. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub body { |
129
|
600
|
|
|
600
|
1
|
3403
|
return $_[0]->{body}; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 AUTHOR |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Simon Wistow |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 COPYRIGHT |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Copyright (c) 2004, Simon Wistow |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|