The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mail::Addressbook::Convert::Pegasus - convert to and from Pegasus addressbooks

SYNOPSIS

use strict;

use Mail::Addressbook::Convert::Pegasus;

my $Pegasus = new Mail::Addressbook::Convert::Pegasus();

my $PegasusMain1File ="PegasusMainSample.txt"; # name of a file containing the Pegasus Addressbook data

my $PegasusMain2File ="PegasusMainSample.txt"; # name of a file containing the Pegasus Addressbook data

my $PegasusDist1InFile ="PegasusDist1Sample.txt"; # name of a the file containing the a distribution list data

my $PegasusDist2InFile ="PegasusDist2Sample.txt"; # name of a the file containing the a distribution list data

# Convert Pegasus to Standard Intermediate format

# see documentation for details on format.

my $raIntermediate = $Pegasus->scan([\$PegasusMain1File ,\PegasusMain2File], [\$PegasusDist1InFile, \$PegasusDist2InFile] );

# This will also work

#my @PegasusMain1Array = @arrayContainingThePegasusMainAddressesData; #my @PegasusMain2Array = @arrayContainingThePegasusMainAddressesData; #my @PegasusDist1Array = @arrayContainingAPegasusDistribution1ListData; #my @PegasusDist2Array = @arrayContainingAPegasusDistribution2ListData; #my @DistNames = qw(Dist1, Dist2);

# The third parameter contains the names of the distribution lists that are in the second parameter. # This parameter is only needed is the lists specified as references to arrays. # if they are specified as files, the third parameter is not necessary.

#my $raIntermediate = $Pegasus->scan([\@PegasusMain1Array,\@PegasusMain2Array], # [\@PegasusDist1Array , \@PegasusDist2Array],\@DistNames );

#( You may put as many distribution lists arrays in the parameters as you wish. )

# Convert back to Pegaus

my @PegaOut = $Pegasus->output($raIntermediate);

#See below for explaination of the output array, and sample code.

REQUIRES

Perl, version 5.001 or higher

Carp File::Basename;

DESCRIPTION

This module is meant to be used as part of the Mail::Addressbook::Convert distribution.

It can convert a Pegasus addressbook to a Standard Intermediate format(STF) and a STF to Ldif As part of the larger distribution, it will allow conversion between Pegasus and many other formats.

To use to convert between Pegaus and Eudora as an example, you would do the following

use Mail::Addressbook::Convert::Pegasus;

use Mail::Addressbook::Convert::Eudora;

my $Pegasus = new Mail::Addressbook::Convert::Pegasus();

my $Eudora = new Mail::Addressbook::Convert::Eudora();

# The main addressbooks must be exported from Pegasus in tagged text format. my $PegasusAddr1InFile ="PegasusAddr1Sample.txt"; # name of a file containing Pegasus Tagged text Addressbook data

my $PegasusAddr2InFile ="PegasusAddr2Sample.txt"; # name of a file containing Pegasus Tagged text Addressbook data

my $PegasusDist1InFile ="PegasusDist1Sample.txt"; # name of the file containing the a distribution list data

my $PegasusDist2InFile ="PegasusDist2Sample.txt"; # name of the file containing the a distribution list data

my $raIntermediate = $Pegasus->scan( [\$PegasusAddr1InFile, \$PegasusAddr2InFile], [\$PegasusDist1InFile, \$PegasusDist2InFile ]); # $raIntermediate is the intermediate (STF) format file described below.

my $raEudora = $Eudora->output($raIntermediate); # reference to an array containing a Eudora addressbook

##------------------------------------------------------------------------

The following code will convert from STF intermediate format and write out Pegasus files

# $raIntermediate is a reference to an intermediate STF file. my @raPegasus = $Pegasus->output($raIntermediate);

my @mainAddressbook = @{$raPegasus[0]}; # This array is in tagged text format and must be imported into Pegasus

open FH , ">PegasusMainAddressBook" or die "Cannot open PegasusMainAddressBook for writing $!"; # This file is in tagged text format and must be imported into Pegasus foreach (@mainAddressbook) { print FH $_; }

close FH;

my @distListArrayRefs = @{$raPegasus[1]}; my $numberOfDistLists = @distListArrayRefs; # an array called in scalar context returns the number #of elements. my @distListArrayNames = @{$raPegasus[2]};

foreach my $i (0..$numberOfDistLists-1) { my $DistListName = $distListArrayNames[$i]; my @DistList = @{$distListArrayRefs[$i]}; open FH , ">$DistListName" or die "Cannot open $DistListName $!"; # Thes files are distribution lists and can be used directly, no conversion required foreach (@DistList) { print FH $_; }

        close FH;

        

}

DEFINITIONS

Standard Intermediate Format(STF) :

                        The addressbook format that is used as an intermediate
                        between conversions.  It is rfc822 compliant and can
                        be used directly as a Eudora addressbook.  Do not use
                        a Eudora addressbook as an STF. Some versions of 
                        Eudora use a format, that while RFC822 compliant, will
                        not work as an STF. Run the Eudora addressbook
                        through $Eudora->scan()
                        

Pegasus addressbook: Pegausus stores its addresses in multiple files. There are one or more addressbooks, and zero or more distribution lists. Each distribution list is in a separate file.

                          The addressbooks cannot be used directly, but must be exported.  Open the
                          addressbook, then use the Addressbook Menu : "Export to Tagged Text File".  The 
                          exported file(s) will be used as imput.
                          
                          The distribution lists are kept in files with a ".pml" extension.  They
                          are used as input directly -- no exporting is necessary. Pegasus does not check
                          for circular references until the distribution list is used.  Be sure that you have 
                          either used the list, or you have checked that there are no circular references.
                        

METHODS

new

no arguments needed.

scan

Input :

Parameter 1; Required: An anonymous array. Each element of the array is either a reference to an array containing the contents of a tagged text file ( exported from an addressbook -- see above under definitions) or a reference to a scalar containing the file name with the tagged text addressbook. The array must contain at least one element.

Parameter 2: Optional: An anonymous array. Each element of the array is either a reference to an array containing the contents of a distribution list (.pml) file or a reference to a scalar containing the distribution list file name.

Parameter 3: Optional: A reference to an array. Each element of the array the name of the corresponding distribution list in Parameter 2. This parameter is only necessary if the elements of parameter 2 are array references. When the elements are references to scalers containing the name of the distribution list files, the distribution list name is taken from file name.

Returns: a reference to a STF ( see above).

output

Input: a reference to a STF ( see above). Returns an array of three items

Return 1: A reference to an array containing the main addressbook in tagged text format. This format can be imported into Pegasus.

Return 2: A reference to an array. Each element of the array is a a reference an array containing a distrubution list.

Return 3: A reference to an array containing the file names of the distribution lists in return 2.

LIMITATIONS

This only converts email address, aliases, and mailing lists. Phone numbers, postal addresses and other such data are not converted.

REFERENCES

You can find information on Pegasus at http://www.pmail.com/

HISTORY

This code is derived from the code used on www.interguru.com/mailconv.htm . The site has been up since 1996 ( but ldif was only included on 1997, when Netscape 3 started using it.) The site gets about 8000 unique visitors a month, many of whom make addressbook conversions. The code has been well tested.

FUTURE DIRECTIONS

BUGS

CHANGES

Original Version 2001-Sept-09

COPYRIGHT

Copyright (c) 2001 Joe Davidson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html). or the GPL copyleft license ( http://www.gnu.org/copyleft/gpl.html)

AUTHOR

Mail::Addressbook::Convert was written by Joe Davidson <jdavidson@interguru.com> in 2001.