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);
}

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).

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.

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..

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

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.