Created
November 10, 2013 14:15
-
-
Save schnell18/7398811 to your computer and use it in GitHub Desktop.
This script convert simple user name and mobile phone in .csv to vCard format so that it can be imported in the mobile phone easily.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use Text::vCard::Addressbook; | |
my $ab = Text::vCard::Addressbook->new(); | |
open my $f, '<', 'address.txt' or die "Can not open file for read: $!\n"; | |
while(<$f>) { | |
chomp; | |
my ($fn, $phone) = split(/\s+/, $_); | |
my $vcard = $ab->add_vcard(); | |
$vcard->fullname($fn); | |
my $mp = $vcard->add_node({ 'node_type' => 'TEL' }); | |
$mp->add_types("cell"); | |
$mp->value($phone); | |
} | |
close($f); | |
open my $out, '>', 'address.vcf' or die "Can't open file for write: $!\n"; | |
print $out $ab->export; | |
close($out); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment