#!/usr/bin/perl use strict; use Palm::Address; use XML::Writer; use IO; # Yes, this is copyright by me. # Palm::Address converter to Sylpheed's XML Format # Format tested on Sylpheed 0.6.4 # See http://sylpheed.good-day.net # Yes, I do know Sylpheed can do this too but that feature failed to c +ompile for me # You need to edit addrbook--index.xml so it has an entry as shown bel +ow. # <book name="Palm" file="addrbook-000003.xml" /> # The bookname can be changed but you'll need to change the source too +. # You need to rename/move the output to the .sylpheed directory in you +r homedir my $pdb = Palm::Address->new(); $pdb->Load("AddressDB.pdb"); my $output = new IO::File(">output.xml"); my $writer = new XML::Writer(OUTPUT => $output,DATA_MODE=>1, DATA_INDE +NT=>3); $writer->xmlDecl("ISO-8859-1"); # This is ok for me, tweak it ! $writer->startTag("address-book","name"=>"Palm"); # Change name here my $id = int rand(300000); # I have NO idea if the UID needs to be sequential but this works foreach my $record (@{$pdb->{records}}) { my $email_loc; for (1..5) { if ($record->{phoneLabel}{"phone$_"} eq "4") { $email_loc = $_; } } # Find which Phone field is for E-Mail if ($record->{fields}{"phone$email_loc"} =~ /\@/) { $id++; $writer->startTag("person","uid"=>$id,"first-name"=>$record->{fiel +ds}{firstName}, "last-name"=>$record->{fields}{name},"nick-name"=>"", "cn"=>$record->{fields}{firstName}." ".$record->{fields}{name}); $writer->startTag("address-list"); my (@addresses) = split (/\n/,$record->{fields}{"phone$email_loc"} +); foreach my $addr(@addresses) { $id++; $writer->startTag("address","uid"=>$id,"alias"=>"","email"=>$ad +dr,"remarks"=>$record->{fields}{note}); $writer->endTag("address"); } $writer->endTag("address-list"); $writer->startTag("attribute-list"); foreach my $key (keys %{$record->{fields}}) { if ($key ne "name" && $key ne "firstName" && $key ne "phone$emai +l_loc" && $key ne "note") { $id++; $writer->startTag("attribute","uid"=>$id,"name"=>$pdb->{appinf +o}{fieldLabels}{$key}); $writer->characters($record->{fields}{$key}); $writer->endTag("attribute"); } } $writer->endTag("attribute-list"); $writer->endTag("person"); } } $writer->endTag("address-book"); $writer->end(); $output->close();

In reply to Palm::Addressbook to Sylpheed addressbook converter by Beatnik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.