Provided by: libtext-vcard-perl_2.13-2_all
NAME
Text::vCard::Addressbook - a package to parse, edit and create multiple vCards (RFC 2426)
SYNOPSIS
To read an existing file: use Text::vCard::Addressbook; my $address_book = Text::vCard::Addressbook->new( { 'source_file' => '/path/to/address.vcf', } ); foreach my $vcard ( $address_book->vcards() ) { print "Got card for " . $vcard->fullname() . "\n"; } To create a new file: use Text::vCard::Addressbook; my $address_book = Text::vCard::Addressbook->new(); my $vcard = $ab->add_vcard; $vcard->fullname('Foo Bar'); $vcard->EMAIL('foo@bar.com'); open my $out, '>', 'address.vcf' or die; print $out $address_book->export;
DESCRIPTION
This package provides an API to reading / editing and creating multiple vCards. A vCard is an electronic business card. This package has been developed based on rfc2426. You will find that many applications (Apple Address book, MS Outlook, Evolution etc) can export and import vCards.
READING IN VCARDS
load() use Text::vCard::Addressbook; # Read in from a list of files my $address_book = Text::vCard::Addressbook->load( [ 'foo.vCard', 'Addresses.vcf' ] ); This method will croak if it is unable to read in any of the files. import_data() $address_book->import_data($value); This method imports data directly from a string. new() # Read in from just one file my $address_book = Text::vCard::Addressbook->new( { 'source_file' => '/path/to/address.vcf', } ); This method will croak if it is unable to read in the source_file. # File already in a string my $address_book = Text::vCard::Addressbook->new( { 'source_text' => $source_text, } ); # Create a new address book my $address_book = Text::vCard::Addressbook->new(); Looping through all vcards in an address book. foreach my $vcard ( $address_book->vcards() ) { $vcard->...; }
METHODS
add_vcard() my $vcard = $address_book->add_vcard(); This method creates a new empty Text::vCard object, stores it in the address book and return it so you can add data to it. vcards() my $vcards = $address_book->vcards(); my @vcards = $address_book->vcards(); This method returns a reference to an array or an array of vcards in this address book. This could be an empty list if there are no entries in the address book. set_encoding() $address_book->set_encoding('utf-8'); This method will add the string ';charset=utf-8' to each and every vCard entry. That does help in connection with e.g. an iPhone... export() my $vcf_file = $address_book->export() This method returns the vcard data in the vcf file format. Please note there is no validation, you must ensure that the correct nodes (FN,N,VERSION) are already added to each vcard if you want to comply with RFC 2426. This might not escape the results correctly at the moment.
AUTHOR
Leo Lapworth, LLAP@cuckoo.org
COPYRIGHT
Copyright (c) 2003 Leo Lapworth. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
ACKNOWLEDGEMENTS
The authors of Text::vFile::asData for making my life so much easier.
SEE ALSO
Text::vCard, Text::vCard::Node