Tema: Re: HTC TyTn II (Kaiser) phonebook atstatymas —> TAIP!
Autorius: sansas | pix.lt
Data: 2010-11-04 01:41:57
exit "Usage: parse_pim.pl filename" unless $ARGV[0];
print "Start parsing..\n";
my $cond = "wait";
my $contact = '';
my %contacts;
open(F, "<".$ARGV[0] );
my $s;
while(read(F, $s, 1) ) {
while($s =~ /./g) {
if( ord($s) == 8 && $cond eq "wait" ) {
$cond = "zero";
} elsif ( ord($s) == 0 && $cond eq "zero" ) {
$cond = "start";
} elsif ( $cond eq "zero" ) {
$cond = "wait";
} elsif ( ( $cond =~ /^start|read$/ || ( $cond > 0 && $cond < 6 )) && ( ( ord($s) >= 48 && ord($s) <= 57 ) || ( ord($s) >= 97 && ord($s) <= 122 ) || ( ord($s) >= 65 && ord($s) <= 90 ) || ord($s) == 32 ) ) {
$contact =~ /(.)$/;
if( ( ord($1) < 48 || ord($1) > 57 ) && ( ord($s) >= 48 && ord($s) <= 57 ) ) {
$contact .= ';';
}
$contact .= $s;
$cond = "read";
} elsif ( $cond eq 'read' ) {
$cond = 1;
} elsif ( $cond >= 4 ) {
$cond = "wait";
$contacts{$contact} = 1 if $contact =~ /\d{5,}/ && $contact =~ /\w+/;
$contact = '';
} elsif ( $cond > 0) {
$cond++;
}
}
}
close(F);
for my $contact (sort keys %contacts) {
print $contact."\n";
}
# I translated the result to Outlook contact list then (because it is possible to synchronize Outlook contact list with my htc3300 WM5 device). Next steps:
# 0. I created CSV template file (with required fields) using Outlook contact export to CSV first. helped me
# 1. I translated the perl prg output to CSV file
# 2. I imported CSV to Outlook contact list.
# 3. I synchronized htc3300 contact list with outlook.