2 my $timestamp= "Time-stamp: \"vcard2abook.pl was last updated on Sun, 17 Dec 2000 10:34am\"";
4 #==============================================================================*
5 # vcard2abook.pl by jeff covey <jeff.covey@pobox.com> *
7 # this script has two main features: *
9 # 1. it converts a file containing addressbook entries in vcard format to *
10 # one containing entries in abook format. *
11 # 2. it almost has more comments than code. *
13 # This program is free software; you can redistribute it and/or modify *
14 # it under the terms of the GNU General Public License as published by *
15 # the Free Software Foundation; either version 2 of the License, or *
16 # (at your option) any later version. *
18 # This program is distributed in the hope that it will be useful, *
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21 # GNU General Public License for more details. *
23 # You should have received a copy of the GNU General Public License *
24 # along with this program; if not, write to the Free Software *
25 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
26 #==============================================================================*
31 "usage: vcard2abook.pl <vcard input file> <abook output file>\noutput file will be overwritten!\n";
33 my $vcards="$ARGV[0]";
34 my $abook ="$ARGV[1]";
39 "NICKNAME" => "nick=",
45 "TEL;HOME" => "phone=",
46 "TEL;PREF" => "phone=",
47 "TEL;VOICE" => "phone=",
48 "TEL;MSG" => "phone=",
49 "TEL;VIDEO" => "phone=",
50 "TEL;MODEM" => "phone=",
51 "TEL;ISDN" => "phone=",
52 "TEL;WORK" => "workphone=",
53 "TEL;CELL" => "mobile=",
54 "TEL;PAGER" => "mobile=",
55 "TEL;CAR" => "mobile=",
59 open (VCARDS,"$vcards") or quit("couldn't open $vcards");
60 open (ABOOK,">$abook") or quit("couldn't open $abook for writing");
64 elsif (/^BEGIN:VCARD/i) { print ABOOK "[]\n"; }
65 elsif (/^END:VCARD/i) { print ABOOK "\n"; }
67 chomp; my @sections=split /:/, $_, 2;
68 if ($sections[0] =~ /^ADR/i) {
69 my @fields=split /;/, $sections[1];
70 if ($fields[2]) {print ABOOK "address=$fields[2]\n";}
71 if ($fields[3]) {print ABOOK "city=$fields[3]\n"; }
72 if ($fields[4]) {print ABOOK "state=$fields[4]\n"; }
73 if ($fields[5]) {print ABOOK "zip=$fields[5]\n"; }
74 if ($fields[6]) {print ABOOK "country=$fields[6]\n";}
77 foreach $key (keys %conversions) {
78 if ($sections[0] =~ /^$key/i) {
79 print ABOOK "$conversions{$key}$sections[1]\n";
86 close (VCARDS) or quit("couldn't close $vcards");
87 close (ABOOK) or quit("couldn't close $abook");
90 print "whoops! $_[0]:\n $!\n"; die;