The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


RDF::vCard::Importer - import RDF data from vCard format


 use RDF::vCard;
 use RDF::TrineShortcuts qw':all';
 my $importer = RDF::vCard::Importer->new;
 print $_
        foreach $importer->import_file('contacts.vcf');
 print rdf_string($importer->model => 'RDFXML');


This module reads vCards and writes RDF.


  • new(%options)

    Returns a new RDF::vCard::Importer object and initialises it.

    The only valid option currently is ua which can be set to an LWP::UserAgent for those rare occasions that the Importer needs to fetch stuff from the Web.


  • init

    Reinitialise the importer. Forgets any cards that have already been imported.

  • model

    Return an RDF::Trine::Model containing data for all cards that have been imported since the importer was last initialised.

  • import_file($filename, %options)

    Imports vCard data from a file on the file system.

    The data is added to the importer's model (and can be retrieved using the model method).

    This function returns a list of RDF::vCard::Entity objects, so it's also possible to access the data that way.

    There is currently only one supported option: lang which takes an ISO language code indicating the default language of text within the vCard data.

  • import_fh($filehandle, %options)

    As per import_file, but operates on a file handle.

  • import_string($string, %options)

    As per import_file, but operates on vCard data in a string.

  • import_url($url)

    As per import_file, but fetches vCard data from a Web address.

    Sends an HTTP Accept header of:


vCard Input

vCard 3.0 should be supported fairly completely. Some vCard 4.0 constructs will also work.

Much of the heavy lifting is performed by Text::vFile::asData, so this module may be affected by bugs in that distribution.

RDF Output

Output uses the newer of the 2010 revision of the W3C's vCard vocabulary (Note that even though this was revised in 2010, the term URIs include "2006" in them.)

Some extensions from the namespace are also output.

The AGENT property is currently omitted from output. This will be added in a later version.




Toby Inkster <>.


Copyright 2011 Toby Inkster

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.