| 1 | =head1 NAME | ||
| 2 | |||
| 3 | Mail::Addressbook::Convert::Tsv - convert to and from Tsv ( Tab Separated )formatted addressbooks | ||
| 4 | |||
| 5 | =head1 SYNOPSIS | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | |||
| 9 | use Mail::Addressbook::Convert::Tsv; | ||
| 10 | |||
| 11 | my $TSV = new Mail::Addressbook::Convert::Tsv(); | ||
| 12 | |||
| 13 | my $TsvInFile ="csvSample.txt"; # name of the file containing the csv data | ||
| 14 | |||
| 15 | # Convert Tsv to Standard Intermediate format | ||
| 16 | |||
| 17 | # see documentation for details on format. | ||
| 18 | |||
| 19 | my $raIntermediate = $TSV->scan(\$CsvInFile); | ||
| 20 | |||
| 21 | # This will also work | ||
| 22 | |||
| 23 | #my @TsvInArray = @arrayContainingTheCsvData; | ||
| 24 | |||
| 25 | #my $raIntermediate = $csv->scan(\@TsvInArray); | ||
| 26 | |||
| 27 | |||
| 28 | # Convert back to Tsv | ||
| 29 | |||
| 30 | my $raTsvOut = $TSV->output($raIntermediate); | ||
| 31 | |||
| 32 | print join "", @$raIntermediate; | ||
| 33 | |||
| 34 | print "\n\n\n\n"; | ||
| 35 | |||
| 36 | print join "", @$raTsvOut; | ||
| 37 | |||
| 38 | =head1 REQUIRES | ||
| 39 | |||
| 40 | Perl, version 5.001 or higher | ||
| 41 | |||
| 42 | Carp | ||
| 43 | |||
| 44 | =head1 DESCRIPTION | ||
| 45 | |||
| 46 | This module is meant to be used as part of the Mail::Addressbook::Convert distribution. | ||
| 47 | |||
| 48 | It can convert a Tsv addressbook to a Standard Intermediate format(STF) and a STF to TSV | ||
| 49 | As part of the larger distribution, it will allow conversion between Tsv and many other | ||
| 50 | formats. | ||
| 51 | |||
| 52 | To use to convert between Tsv and Eudora as an example, you would do the following | ||
| 53 | |||
| 54 | use Mail::Addressbook::Convert::Tsv; | ||
| 55 | |||
| 56 | use Mail::Addressbook::Convert::Eudora; | ||
| 57 | |||
| 58 | my $Tsv = new Mail::Addressbook::Convert::Tsv(); | ||
| 59 | |||
| 60 | my $Eudora = new Mail::Addressbook::Convert::Eudora(); | ||
| 61 | |||
| 62 | my $tsvInFile ="tsvSample.txt"; # name of the file containing the Tsv data | ||
| 63 | |||
| 64 | my $raIntermediate = $Tsv->scan(\$tsvInFile); | ||
| 65 | |||
| 66 | my $raEudora = $Eudora->output($raIntermediate); # reference to an array containing a Eudora addressbook | ||
| 67 | |||
| 68 | |||
| 69 | =head1 DEFINITIONS | ||
| 70 | |||
| 71 | Standard Intermediate Format(STF) : | ||
| 72 | |||
| 73 | The addressbook format that is used as an intermediate | ||
| 74 | between conversions. It is rfc822 compliant and can | ||
| 75 | be used directly as a Eudora addressbook. Do not use | ||
| 76 | a Eudora addressbook as an STF. Some versions of | ||
| 77 | Eudora use a format, that while RFC822 compliant, will | ||
| 78 | not work as an STF. Run the Eudora addressbook | ||
| 79 | through $Eudora->scan() | ||
| 80 | |||
| 81 | Tsv addressbook: | ||
| 82 | |||
| 83 | |||
| 84 | The tab seperated columns are described below. Only the first one is mandatory. | ||
| 85 | They may be enclosed in quotes. | ||
| 86 | |||
| 87 | E-mail address. | ||
| 88 | Name 1 Usually first name or full name. | ||
| 89 | Name 2 Usually last name or leave blank | ||
| 90 | Alias A unique alias, if it is not unique, it will be made unique. If it is left blank, a unique alias will be produced from the name portion of the e-mail address (the part to the left of the "@" sign). | ||
| 91 | Comment | ||
| 92 | In the following columns, as many as needed, put the names of any mailing lists (address list, distribution lists, etc.) that you want this address to be included in. | ||
| 93 | |||
| 94 | Two Examples: | ||
| 95 | |||
| 96 | Using only column 1 | ||
| 97 | jdavidson@interguru.com | ||
| 98 | Using Columns 1 and 4 | ||
| 99 | jdavidson@interguru.com<tab><tab>jhd | ||
| 100 | |||
| 101 | The spaces in the example are tabs. | ||
| 102 | |||
| 103 | A full Example ------------------------------------------------ | ||
| 104 | |||
| 105 | jhd@radix.net Joe Davidson1 jhd comment1 lista | ||
| 106 | jdavidson@interguru.com Joe Davidson2 lista listb | ||
| 107 | jhd@radix.net Joe Davidson3 comment3 | ||
| 108 | jhd@radix.net Joe Davidson4 comment4 listb listc | ||
| 109 | kingtut@noplace.edu King Tut | ||
| 110 | queeenofsheba@kush.com | ||
| 111 | |||
| 112 | ------------------------------------------------------ | ||
| 113 | =head1 METHODS | ||
| 114 | |||
| 115 | =head2 new | ||
| 116 | |||
| 117 | no arguments needed. | ||
| 118 | |||
| 119 | =head2 scan | ||
| 120 | |||
| 121 | Input : a reference to an array containing a tsv file or a reference to a scalar containing | ||
| 122 | the file name with the tsv data. | ||
| 123 | Returns: a reference to a STF ( see above). | ||
| 124 | |||
| 125 | =head2 output | ||
| 126 | |||
| 127 | Input: a reference to a STF ( see above). | ||
| 128 | Returns : a reference to an array containing a tsv file. | ||
| 129 | |||
| 130 | |||
| 131 | =head1 LIMITATIONS | ||
| 132 | |||
| 133 | This only converts email address, aliases, and mailing lists. Phone numbers, | ||
| 134 | postal addresses and other such data are not converted. | ||
| 135 | |||
| 136 | |||
| 137 | |||
| 138 | =head1 REFERENCES | ||
| 139 | |||
| 140 | |||
| 141 | |||
| 142 | |||
| 143 | |||
| 144 | =head1 HISTORY | ||
| 145 | |||
| 146 | This code is derived from the code used on www.interguru.com/mailconv.htm . The site | ||
| 147 | has been up since 1996 ( but ldif was only included on 1997, when Netscape 3 started | ||
| 148 | using it.) The site gets about 8000 unique visitors a month, many of whom make addressbook | ||
| 149 | conversions. The code has been well tested. | ||
| 150 | |||
| 151 | =head1 FUTURE DIRECTIONS | ||
| 152 | |||
| 153 | |||
| 154 | |||
| 155 | |||
| 156 | =head1 SEE ALSO | ||
| 157 | |||
| 158 | |||
| 159 | |||
| 160 | =head1 BUGS | ||
| 161 | |||
| 162 | =head1 CHANGES | ||
| 163 | |||
| 164 | Original Version 2001-Sept-09 | ||
| 165 | |||
| 166 | =head1 COPYRIGHT | ||
| 167 | |||
| 168 | Copyright (c) 2001 Joe Davidson. All rights reserved. | ||
| 169 | This program is free software; you can redistribute it | ||
| 170 | and/or modify it under the terms of the Perl Artistic License | ||
| 171 | (see http://www.perl.com/perl/misc/Artistic.html). or the | ||
| 172 | GPL copyleft license ( http://www.gnu.org/copyleft/gpl.html) | ||
| 173 | |||
| 174 | |||
| 175 | =head1 AUTHOR | ||
| 176 | |||
| 177 | Mail::Addressbook::Convert was written by Joe Davidson <jdavidson@interguru.com> in 2001. | ||
| 178 | |||
| 179 | =cut | ||
| 180 | |||
| 181 | #------------------------------------------------------------------------------ | ||
| 182 | |||
| 183 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 184 | |||
| 185 | 1 | ▶ | use Mail::Addressbook::Convert::Genr; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 186 | |||
| 187 | package Mail::Addressbook::Convert::Tsv; | ||
| 188 | |||
| 189 | |||
| 190 | 1 | ▶ | use 5.001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 191 | |||
| 192 | 1 | ▶ | use vars qw(@ISA ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 193 | 1 | @ISA = qw { Mail::Addressbook::Convert::Genr }; | |
| 194 | |||
| 195 | ############# Constructor ########################################## | ||
| 196 | |||
| 197 | # new is inherited | ||
| 198 | |||
| 199 | |||
| 200 | ###################################################################### | ||
| 201 | |||
| 202 | sub scan | ||
| 203 | 1 | ▶ | { |
|
Subroutine
scan: called CC=1 SCAR=0.0
Pod
documented
| |||
| 204 | 1 | my $Csv = shift; | |
| 205 | 1 | my $inputParm=shift; | |
| 206 | 1 | $Csv->setfileFormat("tsv"); | |
| 207 | 1 | $Csv->SUPER::scan($inputParm); | |
| 208 | |||
| 209 | |||
| 210 | } | ||
| 211 | # sub output is inherited from genr. | ||
| 212 | |||
| 213 | sub output | ||
| 214 | 1 | ▶ | { |
|
Subroutine
output: called CC=1 SCAR=0.0
Pod
documented
| |||
| 215 | 1 | my $Csv = shift; | |
| 216 | 1 | my $inputParm=shift; | |
| 217 | 1 | $Csv->setfileFormat("tsv"); | |
| 218 | 1 | $Csv->SUPER::output($inputParm); | |
| 219 | |||
| 220 | |||
| 221 | } | ||
| 222 | |||
| 223 | 1 | 1; | |