| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | =head1 NAME | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | Mail::Addressbook::Convert::Mailrc  - from Unix Mailrc Addressbook | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | use strict; | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | use Mail::Addressbook::Convert::Mailrc; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | my $Mailrc = new Mail::Addressbook::Convert::Mailrc(); | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | my $MailrcInFile  ="mailrc";  # name of the file containing the Spry data | 
| 14 |  |  |  |  |  |  | # it is found in the Spry folder | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | # Convert Mailrc to Standard Intermediate format | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | # see documentation for details on format. | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | my $raIntermediate = $Mailrc->scan(\$MailrcInFile); | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | # This will also work | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | #my @MailrcInArray  = @arrayContainingTheMailrcData; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | #my $raIntermediate = $Mailrc->scan(\@MailrcInArray); | 
| 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 Tsv addressbook to a Standard Intermediate format(STF) and a STF to TSV | 
| 46 |  |  |  |  |  |  | As part of the larger distribution, it will allow conversion between Spry and many other | 
| 47 |  |  |  |  |  |  | formats. | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | To use to convert between Mailrc and Eudora as an example, you would do the following | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | use Mail::Addressbook::Convert::Mailrc; | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | use Mail::Addressbook::Convert::Eudora; | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | my $Mailrc = new Mail::Addressbook::Convert::Mailrc(); | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | my $Eudora = new Mail::Addressbook::Convert::Eudora(); | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | my $mailrcInFile  ="MailrcSampleFile.txt";  # name of the file containing the mailrc data | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | my $raIntermediate = $Mailrc->scan(\$mailrcInFile); | 
| 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 |  |  |  |  |  |  | Mailrc addressbook: | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | if you are using UNIX mail, you don't need a lot of instructions. | 
| 81 |  |  |  |  |  |  | for details see http://www.unet.univie.ac.at/aix/files/aixfiles/mailrc.htm | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | ------------------------------------------------------ | 
| 85 |  |  |  |  |  |  | =head1 METHODS | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | =head2 new | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | no arguments needed. | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | =head2 scan | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | Input : a reference to an array containing a mailrc file or a reference to a scalar containing | 
| 94 |  |  |  |  |  |  | the file name with the mailrc data. | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | Returns:  a reference to a STF ( see above). | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =head2 output | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | There is no output method.  That is you cannot convert to a Mailrc format. | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | =head1 LIMITATIONS | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | This only converts email address, aliases, and mailing lists.  Phone numbers, | 
| 106 |  |  |  |  |  |  | postal addresses and other such data are not converted. | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | =head1 REFERENCES | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =head1  HISTORY | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | This code is derived from the code used on www.interguru.com/mailconv.htm .  The site | 
| 119 |  |  |  |  |  |  | has been up since 1996 ( but ldif was only included on 1997, when Netscape 3  started | 
| 120 |  |  |  |  |  |  | using it.)  The site gets about 8000 unique visitors a month, many of whom make addressbook | 
| 121 |  |  |  |  |  |  | conversions. The code has been well tested. | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | =head1 FUTURE DIRECTIONS | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | =head1 BUGS | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =head1 CHANGES | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | Original Version 2001-Sept-09 | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | Copyright (c) 2001 Joe Davidson. All rights reserved. | 
| 141 |  |  |  |  |  |  | This program is free software; you can redistribute it | 
| 142 |  |  |  |  |  |  | and/or modify it under the terms of the Perl Artistic License | 
| 143 |  |  |  |  |  |  | (see http://www.perl.com/perl/misc/Artistic.html). or the | 
| 144 |  |  |  |  |  |  | GPL copyleft license ( http://www.gnu.org/copyleft/gpl.html) | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | =head1 AUTHOR | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | Mail::Addressbook::Convert was written by Joe Davidson   in 2001. | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | =cut | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | #------------------------------------------------------------------------------ | 
| 154 |  |  |  |  |  |  |  | 
| 155 | 1 |  |  | 1 |  | 1089 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 50 |  | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  |  | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | package  Mail::Addressbook::Convert::Mailrc; | 
| 160 |  |  |  |  |  |  |  | 
| 161 | 1 |  |  | 1 |  | 6 | use Mail::Addressbook::Convert::Eudora; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 22 |  | 
| 162 | 1 |  |  | 1 |  | 5 | use Mail::Addressbook::Convert::Utilities; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 86 |  | 
| 163 | 1 |  |  | 1 |  | 6 | use Carp; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 64 |  | 
| 164 |  |  |  |  |  |  |  | 
| 165 |  |  |  |  |  |  |  | 
| 166 | 1 |  |  | 1 |  | 20 | use  5.001; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 54 |  | 
| 167 |  |  |  |  |  |  |  | 
| 168 | 1 |  |  | 1 |  | 6 | use vars qw(@ISA ); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 322 |  | 
| 169 |  |  |  |  |  |  | @ISA = qw { Mail::Addressbook::Convert::Eudora }; | 
| 170 |  |  |  |  |  |  |  | 
| 171 |  |  |  |  |  |  | #############  Constructor ########################################## | 
| 172 |  |  |  |  |  |  |  | 
| 173 |  |  |  |  |  |  | # new is inherited | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  |  | 
| 176 |  |  |  |  |  |  | ###################################################################### | 
| 177 |  |  |  |  |  |  |  | 
| 178 |  |  |  |  |  |  | sub scan | 
| 179 |  |  |  |  |  |  | { | 
| 180 |  |  |  |  |  |  |  | 
| 181 | 1 |  |  | 1 | 1 | 8 | my $Mailrc = shift; | 
| 182 | 1 |  |  |  |  | 3 | my $inputParm=shift; | 
| 183 |  |  |  |  |  |  |  | 
| 184 | 1 |  |  |  |  | 6 | my $raMailrcArray= getInput($inputParm); | 
| 185 |  |  |  |  |  |  |  | 
| 186 |  |  |  |  |  |  |  | 
| 187 | 1 |  |  |  |  | 4 | my @outputFile; | 
| 188 | 1 |  |  |  |  | 3 | foreach (@$raMailrcArray) | 
| 189 |  |  |  |  |  |  | { | 
| 190 | 9 |  |  |  |  | 20 | s/^\s+//; | 
| 191 | 9 | 100 |  |  |  | 26 | next unless /^alias/; | 
| 192 |  |  |  |  |  |  | #chomp; | 
| 193 | 3 |  |  |  |  | 14 | s/\s+/ /g; | 
| 194 | 3 |  |  |  |  | 11 | s/\s*,\s*/,/g; | 
| 195 | 3 |  |  |  |  | 6 | push (@outputFile,$_); | 
| 196 |  |  |  |  |  |  | } | 
| 197 |  |  |  |  |  |  |  | 
| 198 | 1 |  |  |  |  | 10 | return $Mailrc->SUPER::scan(\@outputFile); | 
| 199 |  |  |  |  |  |  |  | 
| 200 |  |  |  |  |  |  |  | 
| 201 |  |  |  |  |  |  | } | 
| 202 |  |  |  |  |  |  |  | 
| 203 |  |  |  |  |  |  |  | 
| 204 |  |  |  |  |  |  | sub output | 
| 205 |  |  |  |  |  |  | { | 
| 206 | 0 |  |  | 0 | 1 |  | confess "\nMailRc.pm does not have an output method. \n You cannot convert to Mailrc"; | 
| 207 |  |  |  |  |  |  |  | 
| 208 |  |  |  |  |  |  |  | 
| 209 |  |  |  |  |  |  | } | 
| 210 |  |  |  |  |  |  |  | 
| 211 |  |  |  |  |  |  | 1; |