The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Convert::Addressbook::Mozilla2Blackberry - Perl extension for converting a CSV comma delimited addressbook from Mozilla to Blackbery csv import format

SYNOPSIS

        use Mozilla::Mork;
        use Convert::Addressbook::Mozilla2Blackberry;
        
        #get the file from the command line or quit with an error
        $file = $ARGV[0];
        unless ($file) { die "Useage: $0 <filename>\n"; }

        #access the address book and setup the memory structure
        my $MorkDetails = Mozilla::Mork->new($file);

        #get a reference to an array of hash's
        my $results = $MorkDetails->ReturnReferenceStructure();
        #create an instance of the converter code
        my $converter = Convert::Addressbook::Mozilla2Blackberry->new();
        #print the Blackberry File headers
        $converter->PrintBlackberryHeaders();

        #process those results
        # for each line in the database
        # each line in the database corresponds to an address book record
        # pass this reference to the StreamConvert routine which will 
        # convert and print it
        
        for my $record_array ( @{$results} )
        {
                $converter->StreamConvert($record_array);
        }

DESCRIPTION

This is a module that builds on the Mozilla::Mork module to translate the Mozilla address book to a CSV format suitable for importing into a Blackberry via the Desktop Manager (i.e. even the CSv fields are in the correct order).

Assumptions

 1. the calling routine knows the correct format to send it in.
 2. the 'right format' is a hash containing a set of records to convert as produced by Mozilla::Mork
 3. this is not a full file conversion - some fields are missing, if there is no corresponding field, also, some fields are created from, or imported from others
 4. You want to print the results so you can capture the output to a file of of your choice.

Caveats

 It turns out that the import engine that comes with the Blackberry Desktop (I tested with version 4.0) will happily import duplicates, even if you tell it not to; so I suggest this for a bulk load only, rather than multiple import runs.  For a ongoing conversion I suggest using the Sync with Outlool/Outlook Express and using Dawn (See Also, below) to manage the combining and conversion.
 I might write a conversion routine, but so far I've shaved my particular yak.

Also, the correct place for this code, if I am being honest is an addtion to the Mail::Addressbook::Convert suite. However, my time to work on this is limited and by releasing in this way I can get it 'out there' for others to use. If someone wants to incorporate it in athe abobe namespace, good for them. I plan to, but no idea when I'll actually get round to it..

Routines

new()

create the new() OO Object. Don't mind the man behind the curtain..

PrintBlackberryHeaders()

print the blackberry field headers - iterate over ever instance and print it, basically.

ReturnBlackberryHeaders()

return a list of the Header fields that Blackberry uses in its .CSV import file

StreamConvert()

Convert each record passed, from each line in an array expects a hash reference which contains a set of data to convert This only converts one set of records at a time, to convert the entire file, you must call it repeatedly. Returns a single scalar containing the CSV record set of the converted record, along with printing the record to STDOUT. #TODO seperate the printing and returning routines

Formats

 not that its needed here, but the Mozilla 'export' file format is:
 First,Last,Display,Nickname,email,screen name,Work Phone,home phone,fax
 pager,mobile

 Blackberry import format is reachable with ReturnBlackberryHeaders(), above.

EXPORT

None by default.

SEE ALSO

Also see Mozilla::Mork

Dawn is a decent Windows addressbook converter program thar handles Mozilla Mork formats (unusually); http://www.joshie.com/projects/dawn/

Thanks to my company for giving me time work on this and release it to the public domain (http://www.ipaccess.com)

Thanks to Brian d Foy who took the time to assist me with the name convention.

I'll probably put up a web page here eventually: http://www.kript.net

AUTHOR

John Constable, <cpan@kript.net<gt>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by John Constable

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.