Skip to content

Instantly share code, notes, and snippets.

@schnell18
Created November 10, 2013 14:15
Show Gist options
  • Save schnell18/7398811 to your computer and use it in GitHub Desktop.
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.
#!/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