| 1 | =head1 NAME | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | Mail::Addressbook::Convert::Genr - base class for many email conversion classes | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | This class is not meant to be called by the user. It is the base class for | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Juno.pm | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | Spry.pm | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Csv.pm | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Tsv.pm | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | Compuserve.pm | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | These classes will convert csv (comma separated variables), tsv (tab separated variables), | ||||||||||||||||||||||||||||
| 20 | sprymail exports, juno address exports. | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 REQUIRES | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | Perl, version 5.001 or higher | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | Carp | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | This is a base class designed for other modules in this distribution. | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head1 DEFINITIONS | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | Standard Intermediate Format(STF) : | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | The addressbook format that is used as an intermediate | ||||||||||||||||||||||||||||
| 37 | between conversions. It is rfc822 compliant and can | ||||||||||||||||||||||||||||
| 38 | be used directly as a Eudora addressbook. Do not use | ||||||||||||||||||||||||||||
| 39 | a Eudora addressbook as an STF. Some versions of | ||||||||||||||||||||||||||||
| 40 | Eudora use a format, that while RFC822 compliant, will | ||||||||||||||||||||||||||||
| 41 | not work as an STF. Run the Eudora addressbook | ||||||||||||||||||||||||||||
| 42 | through $Eudora->scan() | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =head1 METHODS | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =head2 new | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | no arguments needed. | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head2 scan | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | Input : a reference to an array containing input data. | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | Returns: a reference to a STF ( see above). | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =head2 output | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | Input: a reference to a STF ( see above). | ||||||||||||||||||||||||||||
| 60 | Returns : a reference to an array containing the output file. | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head2 setfileFormat | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | Sets the file format must be called before calling scan or output. | ||||||||||||||||||||||||||||
| 65 | Input, | ||||||||||||||||||||||||||||
| 66 | must be one of following "csv","tsv","spry","compuserve" before calling scan | ||||||||||||||||||||||||||||
| 67 | must be one of following "csv","tsv" before calling scan | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head1 LIMITATIONS | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | This only converts email address, aliases, and mailing lists. Phone numbers, | ||||||||||||||||||||||||||||
| 74 | postal addresses and other such data are not converted. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head1 REFERENCES | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =head1 HISTORY | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | This code is derived from the code used on www.interguru.com/mailconv.htm . The site | ||||||||||||||||||||||||||||
| 86 | has been up since 1996 ( but ldif was only included on 1997, when Netscape 3 started | ||||||||||||||||||||||||||||
| 87 | using it.) The site gets about 8000 unique visitors a month, many of whom make addressbook | ||||||||||||||||||||||||||||
| 88 | conversions. The code has been well tested. | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head1 FUTURE DIRECTIONS | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =head1 BUGS | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =head1 CHANGES | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | Original Version 2001-Sept-09 | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | Copyright (c) 2001 Joe Davidson. All rights reserved. | ||||||||||||||||||||||||||||
| 104 | This program is free software; you can redistribute it | ||||||||||||||||||||||||||||
| 105 | and/or modify it under the terms of the Perl Artistic License | ||||||||||||||||||||||||||||
| 106 | (see http://www.perl.com/perl/misc/Artistic.html). or the | ||||||||||||||||||||||||||||
| 107 | GPL copyleft license ( http://www.gnu.org/copyleft/gpl.html) | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | Mail::Addressbook::Convert was written by Joe Davidson <jdavidson@interguru.com> in 2001. | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =cut | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | package Mail::Addressbook::Convert::Genr; | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 1 | ▶ | use Carp qw(croak confess) ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 1 | ▶ | use Mail::Addressbook::Convert::Eudora; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 127 | 1 | ▶ | use Mail::Addressbook::Convert::Utilities; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 128 | 1 | ▶ | use Mail::Addressbook::Convert::PersistentUtilities; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 129 | 1 | ▶ | use Mail::Addressbook::Convert::Pine; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 130 | 1 | ▶ | use 5.001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | ###################################################################### | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 135 | 3 | bless { | |||||||||||||||||||||||||||
| 136 | separator => "", | ||||||||||||||||||||||||||||
| 137 | fileFormat => "", | ||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | ,shift; | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | ###################################################################### | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | sub setfileFormat | ||||||||||||||||||||||||||||
| 147 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
setfileFormat: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 148 | 5 | my $Genr = shift; | |||||||||||||||||||||||||||
| 149 | 5 | $Genr->{fileFormat} = shift; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | ###################################################################### | ||||||||||||||||||||||||||||
| 160 | 3 | ▶ | sub scan { | ||||||||||||||||||||||||||
|
Subroutine
scan: called CC=25 SCAR=38.7
Pod
documented
| |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 3 | my $Genr = shift; | |||||||||||||||||||||||||||
| 163 | 3 | my $fileFormat= $Genr->{fileFormat}; | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 3 | my $perUtil = new Mail::Addressbook::Convert::PersistentUtilities(); | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 3 | my $inputParm = shift; # reference to input data as an array reference | |||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 3 | my $raGenrArray= getInput($inputParm); | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 3 | my @file= @$raGenrArray; | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | unless ($fileFormat) {confess "file format not specified\n"}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 3 | ▶ | if ($fileFormat !~ /^csv$|^tsv$|^spry$|^compuserve$/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 0 | {confess qq(\nFile format "$fileFormat" is not supported );} | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 3 | my (%listMember,@outputFile, @comment, @address, $totalAddress); | |||||||||||||||||||||||||||
| 185 | 3 | my ($totalName , @firstName, @lastName); | |||||||||||||||||||||||||||
| 186 | 3 | my ( $ai, @temp, $individualAliasNumber); | |||||||||||||||||||||||||||
| 187 | 3 | my ($AAA, @a, $tempAlias, @b, $i, $j, %aliasList, @alias); | |||||||||||||||||||||||||||
| 188 | 3 | my ($tempAlias1, %existingListAlias); | |||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 3 | my $separator = "\t"; | |||||||||||||||||||||||||||
| 191 | 3 | ▶ | $separator = "," if ($fileFormat eq "csv"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 3 | foreach my $i (0..$#file) | |||||||||||||||||||||||||||
| 195 | { #Block 1 | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 27 | chomp $file[$i]; | |||||||||||||||||||||||||||
| 198 | 27 | ▶ | next unless $file[$i]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 23 | $file[$i] =~ s/\r|\015//g; | |||||||||||||||||||||||||||
| 200 | ##### for Spry Mail ######## | ||||||||||||||||||||||||||||
| 201 | 23 | ▶ | if ($fileFormat eq "spry") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||
| 203 | 0 | my ($a1,$b1) = split(":",$file[$i]); | |||||||||||||||||||||||||||
| 204 | 0 | $file[$i] = $b1."\t".$a1; | |||||||||||||||||||||||||||
| 205 | 0 | $file[$i] =~s/,/SPRYCOMMA/g; | |||||||||||||||||||||||||||
| 206 | #print "JHD SPRY file = $file[$i]\n"; | ||||||||||||||||||||||||||||
| 207 | 0 | undef $ai; | |||||||||||||||||||||||||||
| 208 | 0 | undef $b1; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | ###### end SpryMail ########################## | ||||||||||||||||||||||||||||
| 211 | ##### all formats below ################## | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 23 | @temp = split($separator,$file[$i]); | |||||||||||||||||||||||||||
| 214 | 23 | foreach (@temp) {s/^\s*"|"\s*$//;} # get rid of leading and trailing quotes. | |||||||||||||||||||||||||||
| 215 | 23 | { local $^W; # turn off warnings | |||||||||||||||||||||||||||
| 216 | 23 | ($address[$individualAliasNumber],$firstName[$individualAliasNumber], | |||||||||||||||||||||||||||
| 217 | $lastName[$individualAliasNumber],$tempAlias, | ||||||||||||||||||||||||||||
| 218 | $comment[$individualAliasNumber]) | ||||||||||||||||||||||||||||
| 219 | = @temp[0..4]; | ||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | ##### start section for CompuServe ########################## | ||||||||||||||||||||||||||||
| 224 | 23 | ▶ | if ($fileFormat eq "compuserve") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||
| 226 | 0 | $address[$individualAliasNumber] =~ s/INTERNET://g; | |||||||||||||||||||||||||||
| 227 | 0 | ▶ | if ($address[$individualAliasNumber] =~ /\,/ and | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$address[$individualAliasNumber] =~ /\,/ and not $address[$individualAliasNumber] =~ /@/
MC/DC0%0/2
$address[$individualAliasNumber] =~ /\,/ and not $address[$individualAliasNumber] =~ /@/
$address[$individualAliasNumber] =~ /\,/
not $address[$individualAliasNumber] =~ /@/
Truth table0%0/3
A and not(B)
A= $address[$individualAliasNumber] =~ /\,/B= not $address[$individualAliasNumber] =~ /@/
| |||||||||||||||||||||||||||||
| 228 | $address[$individualAliasNumber] !~/@/) | ||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||
| 230 | 0 | $address[$individualAliasNumber] =~ s/\"//g; | |||||||||||||||||||||||||||
| 231 | 0 | $address[$individualAliasNumber] =~ s/\,/\./; | |||||||||||||||||||||||||||
| 232 | 0 | $AAA = $address[$individualAliasNumber]; | |||||||||||||||||||||||||||
| 233 | 0 | $address[$individualAliasNumber] = | |||||||||||||||||||||||||||
| 234 | $AAA.'@compuserve.com'; | ||||||||||||||||||||||||||||
| 235 | 0 | $tempAlias = $firstName[$individualAliasNumber]. | |||||||||||||||||||||||||||
| 236 | $lastName[$individualAliasNumber]; | ||||||||||||||||||||||||||||
| 237 | 0 | ▶ | unless ($tempAlias) {$tempAlias = $AAA;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | ######### end Compuserve Section | ||||||||||||||||||||||||||||
| 241 | 23 | ▶ | unless ($tempAlias) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||
| 243 | { | ||||||||||||||||||||||||||||
| 244 | 21 | local $^W; | |||||||||||||||||||||||||||
| 245 | 21 | @a = split('@',$address[$individualAliasNumber]); | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | 21 | $tempAlias = $a[0]; | |||||||||||||||||||||||||||
| 248 | 21 | ▶ | if ($tempAlias =~ /\"/ ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | { | ||||||||||||||||||||||||||||
| 250 | 0 | @a = split ("\"", $tempAlias); | |||||||||||||||||||||||||||
| 251 | 0 | $tempAlias = $a[$#a]; | |||||||||||||||||||||||||||
| 252 | 0 | @a = split ("\"",$address[$individualAliasNumber]); | |||||||||||||||||||||||||||
| 253 | 0 | $address[$individualAliasNumber] = $a[$#a]; | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | 21 | ▶ | if ($tempAlias =~ /\>/ ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||
| 257 | 0 | @a = split ("<", $tempAlias); | |||||||||||||||||||||||||||
| 258 | 0 | $tempAlias = $a[1]; | |||||||||||||||||||||||||||
| 259 | 0 | @b = split ("\<",$address[$individualAliasNumber]); | |||||||||||||||||||||||||||
| 260 | 0 | $address[$individualAliasNumber] = $b[1]; | |||||||||||||||||||||||||||
| 261 | 0 | $address[$individualAliasNumber] =~ s/\>+//; | |||||||||||||||||||||||||||
| 262 | 0 | $address[$individualAliasNumber] =~ s/\<+//; | |||||||||||||||||||||||||||
| 263 | 0 | ▶ | unless ($firstName[$individualAliasNumber] | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$firstName[$individualAliasNumber] or $lastName[$individualAliasNumber]
MC/DC0%0/2
$firstName[$individualAliasNumber] or $lastName[$individualAliasNumber]
$firstName[$individualAliasNumber]
$lastName[$individualAliasNumber]
Truth table0%0/3
A or B
A= $firstName[$individualAliasNumber]B= $lastName[$individualAliasNumber]
| |||||||||||||||||||||||||||||
| 264 | or $lastName[$individualAliasNumber]) | ||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||
| 266 | 0 | $firstName[$individualAliasNumber] = $b[0]; | |||||||||||||||||||||||||||
| 267 | 0 | $firstName[$individualAliasNumber] =~ s/\"//g; | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | 23 | $tempAlias = $perUtil->makeAliasUnique($tempAlias); | |||||||||||||||||||||||||||
| 272 | 23 | $aliasList{$tempAlias} = 1; | |||||||||||||||||||||||||||
| 273 | 23 | {local $^W; | |||||||||||||||||||||||||||
| 274 | 23 | $alias[$individualAliasNumber] = $tempAlias ; | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 23 | ▶ | if ($temp[5]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 278 | { | ||||||||||||||||||||||||||||
| 279 | 6 | $j = 5; | |||||||||||||||||||||||||||
| 280 | 6 | ▶ | while ($temp[$j] ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | { | ||||||||||||||||||||||||||||
| 282 | 10 | ▶ | if($existingListAlias{$temp[$j]}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | { | ||||||||||||||||||||||||||||
| 284 | 4 | $tempAlias1 = $existingListAlias{$temp[$j]}; | |||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | else | ||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||
| 288 | 6 | $tempAlias1 = $perUtil->makeAliasUnique($temp[$j]); | |||||||||||||||||||||||||||
| 289 | 6 | $existingListAlias{$temp[$j]} = $tempAlias1; | |||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | 10 | {local $^W; | |||||||||||||||||||||||||||
| 292 | $listMember{$tempAlias1} = | ||||||||||||||||||||||||||||
| 293 | 10 | $listMember{$tempAlias1}.$alias[$individualAliasNumber].","; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 10 | $j++ | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | else | ||||||||||||||||||||||||||||
| 300 | { | ||||||||||||||||||||||||||||
| 301 | 17 | local $^W; | |||||||||||||||||||||||||||
| 302 | $listMember{'notonanotherlist'} = | ||||||||||||||||||||||||||||
| 303 | 17 | $listMember{'notonanotherlist'}.$alias[$individualAliasNumber].","; | |||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | 23 | undef (@temp); | |||||||||||||||||||||||||||
| 306 | 23 | { local $^W; | |||||||||||||||||||||||||||
| 307 | $listMember{'everybody'} = | ||||||||||||||||||||||||||||
| 308 | 23 | $listMember{'everybody'}.$alias[$individualAliasNumber].","; | |||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 23 | $individualAliasNumber++; | |||||||||||||||||||||||||||
| 312 | } #End Block 1 | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 3 | foreach $i (0 .. $#address) | |||||||||||||||||||||||||||
| 315 | { | ||||||||||||||||||||||||||||
| 316 | 23 | ▶ | if ($firstName[$i] or $lastName[$i]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$firstName[$i] or $lastName[$i]
MC/DC50%1/2
$firstName[$i] or $lastName[$i]
$firstName[$i]
$lastName[$i]
Truth table66%2/3
A or B
A= $firstName[$i]B= $lastName[$i]
| |||||||||||||||||||||||||||||
| 317 | 19 | {local $^W; | |||||||||||||||||||||||||||
| 318 | 19 | $totalName = $firstName[$i]." ".$lastName[$i]; | |||||||||||||||||||||||||||
| 319 | 19 | $totalAddress = qq{"$totalName"<$address[$i]>}; | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | else | ||||||||||||||||||||||||||||
| 322 | { | ||||||||||||||||||||||||||||
| 323 | 4 | $totalAddress = $address[$i]; | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 23 | push (@outputFile, "alias ".$alias[$i]." ". | |||||||||||||||||||||||||||
| 327 | $totalAddress."\n"); | ||||||||||||||||||||||||||||
| 328 | 23 | ▶ | if ($comment[$i]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | { | ||||||||||||||||||||||||||||
| 330 | 10 | push (@outputFile, "note ".$alias[$i]." ". | |||||||||||||||||||||||||||
| 331 | $comment[$i]."\n"); | ||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 3 | foreach my $listAlias (keys %listMember) | |||||||||||||||||||||||||||
| 337 | { | ||||||||||||||||||||||||||||
| 338 | 12 | chop $listMember{$listAlias}; # get rid of trailing comma | |||||||||||||||||||||||||||
| 339 | push (@outputFile, "alias ".$listAlias." ". | ||||||||||||||||||||||||||||
| 340 | 12 | $listMember{$listAlias}."\n"); | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | # run $Eudora->scan to resolve list addresses into aliases | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 3 | my $Eudo = new Mail::Addressbook::Convert::Eudora(); | |||||||||||||||||||||||||||
| 347 | 3 | my $raOuputFile = $Eudo->scan(\@outputFile); | |||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 3 | return $raOuputFile; | |||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | ########################### sub output ####################### | ||||||||||||||||||||||||||||
| 354 | sub output | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
output: called CC=11 SCAR=24.1
Pod
documented
| |||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 2 | my (@outputFile); | |||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 2 | my $Genr = shift; | |||||||||||||||||||||||||||
| 361 | 2 | my $raInputArray = shift; # reference to input Input data as an array | |||||||||||||||||||||||||||
| 362 | 2 | my $fileFormat= $Genr->{fileFormat}; | |||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | 2 | ▶ | unless ($fileFormat eq 'csv' or $fileFormat eq 'tsv') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$fileFormat eq "csv" or $fileFormat eq "tsv"
MC/DC0%0/2
$fileFormat eq "csv" or $fileFormat eq "tsv"
$fileFormat eq "csv"
$fileFormat eq "tsv"
Truth table66%2/3
A or B
A= $fileFormat eq "csv"B= $fileFormat eq "tsv"
| |||||||||||||||||||||||||||||
| 365 | 0 | {confess "\n Ascii output file format must be specified as 'csv' or 'tsv'\n\n";} | |||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 2 | my $Pine = new Mail::Addressbook::Convert::Pine(); | |||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 2 | my $raPineArray = $Pine->output($raInputArray); | |||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | #print "\njhd4455 PINE \n@$raPineArray\n\n"; | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | 2 | my $sep = "\t"; | |||||||||||||||||||||||||||
| 374 | 2 | ▶ | $sep = ',' if $fileFormat eq 'csv'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 2 | foreach $_ (@$raPineArray) | |||||||||||||||||||||||||||
| 377 | { | ||||||||||||||||||||||||||||
| 378 | #print "JHD53 $_\n"; | ||||||||||||||||||||||||||||
| 379 | 24 | ▶ | next unless /\t/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 380 | 24 | chomp; | |||||||||||||||||||||||||||
| 381 | 24 | my ($alias,$wholeName,$address,$junk,$comment) = | |||||||||||||||||||||||||||
| 382 | split('\t'); | ||||||||||||||||||||||||||||
| 383 | 24 | my ($name1,$name2) = split(',',$wholeName); | |||||||||||||||||||||||||||
| 384 | 24 | $address =~ s/\(|\)//g; | |||||||||||||||||||||||||||
| 385 | 24 | ▶ | $address = &addquotes($address)if $address ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 386 | 24 | ▶ | $name1 = &addquotes($name1) if $name1 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 387 | 24 | ▶ | $name2 = &addquotes($name2) if $name2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 388 | 24 | ▶ | $comment = &addquotes($comment) if $comment ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 389 | 24 | $alias = &addquotes($alias) ; | |||||||||||||||||||||||||||
| 390 | 24 | my $holdLine; | |||||||||||||||||||||||||||
| 391 | 24 | { local $^W; #turn off warnings | |||||||||||||||||||||||||||
| 392 | 24 | $holdLine = join($sep, $address,$name1,$name2,$alias,$comment); | |||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 24 | ▶ | push (@outputFile, $holdLine."\n") if $holdLine =~ /[^"$sep]/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||
| 397 | 2 | return \@outputFile; | |||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | sub addquotes | ||||||||||||||||||||||||||||
| 401 | 84 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
addquotes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 402 | 84 | my $input = shift; | |||||||||||||||||||||||||||
| 403 | 84 | $input =~ s/"//g; | |||||||||||||||||||||||||||
| 404 | 84 | return '"'.$input.'"'; | |||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | ########################### end sub output ####################### | ||||||||||||||||||||||||||||
| 410 | 1 | 1; | |||||||||||||||||||||||||||