Convert/Ccmail.pm

filter: Statementstmt 86.3% 57 / 66 Branchbran 85.0% 17 / 20 Conditioncond 83.3% 5 / 6 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 87.5% 7 / 8 Podpod 100% 2 / 2 totaltotal 85.7% 90 / 105 CC 13 SCAR 22.4
CC
13
Cov
86%
scan
13.8
output
2.0
BEGIN
1.0
CRAP 9.4
« Convert/Eudora.pm ↑ Summary Convert/Pine.pm »
1 =head1 NAME
2  
3 Mail::Addressbook::Convert::Spry - from ccmail Addressbook
4  
5 =head1 SYNOPSIS
6  
7 use strict;
8  
9 use Mail::Addressbook::Convert::Ccmail;
10  
11 my $Ccmail = new Mail::Addressbook::Convert::Ccmail();
12  
13 my $ccMailInFile ="ccmailSample.txt"; # name of the file containing the ccmail data
14  
15  
16 # Convert ccmail to Standard Intermediate format
17  
18 # see documentation for details on format.
19  
20 my $raIntermediate = $Ccmail->scan(\$ccMailInFile);
21  
22 # This will also work
23  
24 #my @ccmailInArray = @arrayContainingTheccmailData;
25  
26 #my $raIntermediate = $Ccmail->scan(\@ccmailInArray);
27  
28  
29  
30  
31 print join "", @$raIntermediate;
32  
33  
34  
35 =head1 REQUIRES
36  
37 Perl, version 5.001 or higher
38  
39 Carp
40  
41 =head1 DESCRIPTION
42  
43 This module is meant to be used as part of the Mail::Addressbook::Convert distribution.
44  
45 It can convert a ccMail addressbook to a Standard Intermediate format(STF)
46 As part of the larger distribution, it will allow conversion between ccMail and many other
47 formats.
48  
49 To use to convert between ccMial and Eudora as an example, you would do the following
50  
51 use Mail::Addressbook::Convert::Ccmail;
52  
53 use Mail::Addressbook::Convert::Eudora;
54  
55 my $Ccmail = new Mail::Addressbook::Convert::Ccmail();
56  
57 my $Eudora = new Mail::Addressbook::Convert::Eudora();
58  
59 my $ccMailInFile ="ccmailSample.txt"; # name of the file containing the ccmail data
60  
61 my $raIntermediate = $Ccmail->scan(\$ccMailInFile);
62  
63 my $raEudora = $Eudora->output($raIntermediate); # reference to an array containing a Eudora addressbook
64  
65  
66 =head1 DEFINITIONS
67
68 Standard Intermediate Format(STF) :
69  
70 The addressbook format that is used as an intermediate
71 between conversions. It is rfc822 compliant and can
72 be used directly as a Eudora addressbook. Do not use
73 a Eudora addressbook as an STF. Some versions of
74 Eudora use a format, that while RFC822 compliant, will
75 not work as an STF. Run the Eudora addressbook
76 through $Eudora->scan()
77
78 ccMail addressbook:
79  
80 * There are two possible input files, you can use either one.
81
82 1. Export your address list to a file, "ccmail.txt".If you have several files you can export them all,
83 and combine them with a word processor.
84 2. Use your private address book directly, you just pick up the file "privdir.ini".
85 It is in the ccmail sub-directory of your windows directory.
86
87 * If you want to export from both files, you can combine both types of files and use them together.
88  
89  
90  
91 =head1 METHODS
92  
93 =head2 new
94  
95 no arguments needed.
96  
97 =head2 scan
98  
99 Input : a reference to an array containing a tsv file or a reference to a scalar containing
100 the file name with the tsv data.
101 Returns: a reference to a STF ( see above).
102  
103 =head2 output
104  
105 There is no output method. That is you cannot convert to a ccmail format.
106  
107  
108 =head1 LIMITATIONS
109  
110 This only converts email address, aliases, and mailing lists. Phone numbers,
111 postal addresses and other such data are not converted.
112  
113  
114  
115 =head1 REFERENCES
116  
117  
118  
119
120  
121 =head1 HISTORY
122  
123 This code is derived from the code used on www.interguru.com/mailconv.htm . The site
124 has been up since 1996 ( but ldif was only included on 1997, when Netscape 3 started
125 using it.) The site gets about 8000 unique visitors a month, many of whom make addressbook
126 conversions. The code has been well tested.
127  
128 =head1 FUTURE DIRECTIONS
129  
130  
131  
132  
133 =head1 SEE ALSO
134  
135  
136  
137 =head1 BUGS
138  
139 =head1 CHANGES
140  
141 Original Version 2001-Sept-09
142
143 =head1 COPYRIGHT
144  
145 Copyright (c) 2001 Joe Davidson. All rights reserved.
146 This program is free software; you can redistribute it
147 and/or modify it under the terms of the Perl Artistic License
148 (see http://www.perl.com/perl/misc/Artistic.html). or the
149 GPL copyleft license ( http://www.gnu.org/copyleft/gpl.html)
150  
151  
152 =head1 AUTHOR
153  
154 Mail::Addressbook::Convert was written by Joe Davidson <jdavidson@interguru.com> in 2001.
155  
156 =cut
157  
158 #------------------------------------------------------------------------------
159  
160 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
161  
162 package Mail::Addressbook::Convert::Ccmail;
163  
164 1 ▶use Mail::Addressbook::Convert::Genr;
Subroutine BEGIN: called CC=1 SCAR=0.0
165 1 ▶use Mail::Addressbook::Convert::Utilities;
Subroutine BEGIN: called CC=1 SCAR=0.0
166 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
167  
168 1 ▶use 5.001;
Subroutine BEGIN: called CC=1 SCAR=0.0
169  
170 1 ▶use vars qw(@ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
171 1 @ISA = qw { Mail::Addressbook::Convert::Genr };
172  
173 ############# Constructor ##########################################
174  
175 # new is inherited
176  
177
178 ######################################################################
179  
180 sub scan
181 1 ▶{
Subroutine scan: called CC=13 SCAR=26.2
Pod documented
182 1 my $Ccmail = shift;
183
184 1 my $inputParm = shift; # reference to input ccMail data as an array or reference to a
185 # scalar containing the name of a file containing the ccMail data.
186
187 1 $Ccmail->setfileFormat("tsv");
188  
189 1 my $raCcMailArray= getInput($inputParm);
190
191 1 my $haveName = 0;
192 1 my $haveAddress = 0;
193 1 my $endOfAddress = 0;
194 1 my ($name, $address, $part, @hold, @outputFile , $comment, $h1, $h2);
195  
196 1 ▶ while (my $line = shift @$raCcMailArray)
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = shift @$raCcMailArray) 59 1 60
197 {
198 59 chomp $line;
199 59 $line =~ s/\r//g;
200 59 ▶ if ($line =~ /^Name/)
Branch: 4 branches
BranchTrueFalseTotal
if ($line =~ /^Name/) { } 13 46 59
elsif ($line =~ /^Addr/) { } 13 33 46
elsif ($line =~ /^Cmts/) { } 13 20 33
elsif ($line =~ /^Entry\d=/) { } 0 20 20
201 {
202 13 $line =~ s/Name: //;
203 13 ▶ if ($line =~ /.+\@.+\..+/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /.+\@.+\..+/) { } 2 11 13
204 {
205 2 $haveName = 1;
206 2 $haveAddress = 1;
207 2 $name = "";
208 2 $address = $line;
209 }
210 else
211 {
212 11 $haveName = 1;
213 11 $name = $line;
214 }
215 }
216 elsif ($line =~ /^Addr/)
217 {
218 13 $line =~ s/^Addr: //g;
219 13 @hold = split(" ",$line);
220 13 ▶ while ($part = shift @hold)
Branch: 1 branch
BranchTrueFalseTotal
if ($part = shift @hold) 31 13 44
221 {
222 31 ▶ if (isValidInternetAddress($part))
Branch: 1 branch
BranchTrueFalseTotal
if (isValidInternetAddress($part)) 9 22 31
223 {
224 9 $haveAddress = 1;
225 9 $address = $part;
226 }
227
228 }
229 }
230 elsif ($line =~ /^Cmts/)
231 {
232 13 $line = substr($line,5);
233 13 $comment = $line;
234 13 $endOfAddress = 1;
235 }
236 elsif ($line =~ /^Entry\d=/)
237 {
238 0 ($h1,$h2) = split("=", $line);
239 0 ▶ if (&::isValidInternetAddress($h2))
Branch: 1 branch
BranchTrueFalseTotal
if (&main::isValidInternetAddress($h2)) 0 0 0
240 {
241 0 $haveName = 1;
242 0 $haveAddress = 1;
243 0 $endOfAddress = 1;
244 0 $name = "";
245 0 $address = $h2;
246 0 undef $comment;
247 }
248 }
249 59 ▶ if ($haveAddress and $haveName and $endOfAddress)
Branch: 1 branch
BranchTrueFalseTotal
if ($haveAddress and $haveName and $endOfAddress) 11 48 59
Condition83%5/6
$haveAddress and $haveName and $endOfAddress
!ll&&!rl&&r
331511
$haveAddress and $haveName
!ll&&!rl&&r
33026
MC/DC66%2/3
$haveAddress and $haveName and $endOfAddress
$haveAddress $haveName $endOfAddress
Truth table75%3/4
A and B and C
A= $haveAddressB= $haveNameC= $endOfAddress
ABCresult
0XX0
10X0
1100
1111
250 {
251 11 $haveName = 0;
252 11 $endOfAddress = 0;
253 11 $haveAddress = 0;
254 11 $address =~ s/<//g;
255 11 $address =~ s/>//g;
256 11 push (@outputFile, $address."\t".$name.
257 "\t\t\t".$comment."\n");
258
259 11 undef $comment;
260 }
261 }
262 # Now we have a tab separated ascii file,
263
264 1 $Ccmail->SUPER::scan(\@outputFile);
265  
266  
267 }
268  
269  
270 sub output
271 0 ▶{
Subroutine output: not called CC=1 SCAR=6.9
Pod documented
272 0 confess "\nCcmail.pm does not have an output method. \n You cannot convert to ccMail";
273  
274  
275 }
276  
277 1 1;
« Convert/Eudora.pm ↑ Summary Convert/Pine.pm »