vCard::AddressBook(3) Read, write, and edit vCard address books


use vCard::AddressBook;
# create the object
my $address_book = vCard::AddressBook->new();
# these methods load vCard formatted data
my $vcard = $address_book->add_vcard; # returns a vCard object
$vcard->full_name('Bruce Banner, PhD');
{ type => ['work'], address => '[email protected]' },
{ type => ['home'], address => '[email protected]' },
# $address_book->vcards() returns an arrayref of vCard objects
foreach my $vcard (@{ $address_book->vcards() }) {
print $vcard->full_name() . "\n";
print $vcard->email_addresses->[0]->{address} . "\n";
# these methods output data in vCard format
my $file = $address_book->as_file('/path/file.vcf'); # write to a file
my $string = $address_book->as_string();


A vCard is a digital business card. vCard and vCard::AddressBook provide an API for parsing, editing, and creating vCards.

This module is built on top of Text::vCard and Text::vCard::AddressBook and provides a more intuitive user interface.


Constructor Arguments

The 'encoding_in' and 'encoding_out' constructor parameters allow you to read and write vCard files with any encoding. Examples of valid values are 'UTF-8', 'Latin1', and 'none'.

Both parameters default to 'UTF-8' and this should just work for the vast majority of people. The latest vCard RFC 6350 only allows UTF-8 as an encoding so most people should not need to use either parameter.

MIME encodings

vCard RFC 6350 only allows UTF-8 but it still permits 8bit MIME encoding schemes such as Quoted-Printable and Base64 which are supported by this module.

Getting and setting values on a vCard object

If you set values on a vCard object they must be decoded values. The only exception to this rule is if you are messing around with the 'encoding_out' constructor arg.

When you get values from a vCard object they will be decoded values.



Creates a new vCard object and adds it to the address book. Returns a vCard object.


Load and parse the contents of $filename. Returns $self so the method can be chained.


Load and parse the contents of $string. This method assumes that $string is decoded (but not MIME decoded). Returns $self so the method can be chained.


Write all the vCards to $filename. Files are written as UTF-8 by default. Dies if not successful.


Returns all the vCards as a single string.


Eric Johnson (kablamo), github ~!at!~ iijo dot org


Thanks to Foxtons <> for making this module possible by donating a significant amount of developer time.