I want to use Text::vCard to import Address Book data and put that data into a CGI.pm object.

So far I can break out the name and address from a vCard but I can't seem to access the phone number data.

Below is the script I'm building for this. Can anyone spot what I'm doing wrong?

Kindest Regards,

--
Bill Stephenson

<code>

#!/usr/local/bin/perl

use strict;
use Text::vCard;
use Text::vCard::Addressbook;

my $address_book = Text::vCard::Addressbook->new({
'source_file' => '/Library/WebServer/CGI-Executables/test/vCard/GroupvCards.vcf',
});

foreach my $vcard ($address_book->vcards()) {

        print $vcard->fullname() ."\n";

        my $addresses = $vcard->get({ 'node_type' => 'addresses' });

        my $address = $addresses->[0];
        
        print $address->street() ."\n";
        print $address->city() ." ";
        print $address->post_code() ."\n";
        print $address->country() ."\n\n";

        print $vcard->email() ."\n";


# these do not work.
#       print $vcard->tel() ."\n";
#       print $vcard->tel->home() ."\n";
#       print $vcard->phones->home() ."\n";


  #this should get all the home and work phone numbers....


        my @types = qw(work home);
        my $nodes = $vcard->get({
                'node_type' => 'tel',
                'types' => \...@types,
        });

  # trying print them all out here

        foreach my $node (@$nodes) {


  # I have tried variations on this but
  # cannot get it to print the phone numbers.
  # I get no errors. Nothing.

                print $node->value();
                print $node->home();
                print $node->tel->home();
                
        }

        print "\n==========================\n\n";

}

</code>

Sample vCard used
GroupvCards.vcf

BEGIN:VCARD
VERSION:3.0
N:Galik;Frankie;;;
FN:Frankie Galik
ORG:Cork Massage;
EMAIL;type=INTERNET;type=HOME;type=pref:t...@test.com
EMAIL;type=INTERNET;type=WORK:te...@test.com
TEL;type=HOME;type=pref:0210000000
TEL;type=CELL:0850000000
TEL;type=WORK:0210000001
item1.ADR;type=HOME;type=pref:;;Test Street;Cork;Cork;;Ireland
item1.X-ABADR:ie
item2.ADR;type=WORK:;;2 Test Street\, Lee Road;Cork;;;Ireland
item2.X-ABADR:ie
CATEGORIES:Ezinvoice Vcard Test
X-ABUID:E8069363-962C-4F44-A1A2-B678C8597D92\:ABPerson
END:VCARD
BEGIN:VCARD
VERSION:3.0
N:Johnston;John;;;
FN:John Johnston
ORG:Apple;
EMAIL;type=INTERNET;type=HOME;type=pref:j...@mac.com
TEL;type=HOME:+35321000000
TEL;type=CELL;type=pref:+353876666666
TEL;type=WORK:+35321000000
item1.ADR;type=HOME;type=pref:;;17 The Mews\nRiver Towers\, Lee Road;Cork;Cork;;
item1.X-ABADR:ie
CATEGORIES:Ezinvoice Vcard Test
X-ABUID:DFBEC94D-55DC-44C6-978E-3AE5CF63EE79\:ABPerson
END:VCARD




--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/


Reply via email to