Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  NET::VFILE (3)

.ds Aq ’


Net::vFile - Generic module which can read and write "vFile" files such as vCard (RFC 2426) and vCalendar (RFC 2445). The result of loading this data is a collection of objects which will grant you easy access to the properties. Then the module can write your objects back to a data file.



    use Net::vCard;

    my $cards = Net::vCard->loadFile( "foo.vCard", "blort.vCard", "whee.vCard" );

    foreach my $card (@$cards) {
        spam ( $card->EMAIL(default) );


The way this processor works is that it reads the vFile line by line.

1 - BEGIN:(.*) tag

   $1 is looked up in classMap; class is loaded; new object of this class is created
   ie/ $Net::vFile::classMap{VCARD}="Net::vCard";

    n.b. classMap is a package variable for Net::vFile

2 - All lines are read and stored until a BEGIN tag (goto 1) or END tag (goto 3) is reached

3 - END:(.*) tag

   Signals that all entry data has been obtained and now the rows of data are processed

4 - Data is concatenated - thanks to Net::iCal for the strategy; the tag label and data are obtained

5 - The data handler is identified via $object->varHandler->{$label}

    There are some generic handlers for common data types such as simple strings, dates, etc. More
    elaborate data types such as N, ADR, etc. need special treatment and are declared explititly
    in classes as "load_XXX" such as "load_N"

You should be able to override and extend the processing by taking as your example and adjusting as necessary.

The resulting data structure is a bit bulky - but is such that it can express vCard data completely and reliably

  Put in a dump of a vCard here



\@objects = loadFile( filename [, filename ... ] ) Loads the vFiles and returns an array of objects
$object = class->new Make a new object
\@objects = Class->load( filehandle ) Loads data from file handle and creates objects as necessary
$object->error Called when a line cannot be successfully decoded


varHandler Returns a hash ref mapping the item label to a handler name. Ie:

        FN          => singleText,
        N           => N,
        NICKNAME    => multipleText,
        PHOTO       => singleBinary,
        BDAY        => singleText,
        ADR         => ADR,

typeDefault Additional information where handlers require type info. Such as ADR - is this a home, postal, or whatever? If not supplied the RFC specifies what types they should default to.

     from vCard:

        ADR     => [ qw(intl postal parcel work) ],
        LABEL   => [ qw(intl postal parcel work) ],
        TEL     => [ qw(voice) ],
        EMAIL   => [ qw(internet) ],

load_singleText Loads a single text item with no processing other than unescape text
_singleText Accessor for single text items
load_singleDate Loads a date creating a DateTime::Format::ICal object. Thanks Dave!
load_singleDuration Loads a data duration using DateTime::Format::ICal.
load_multipleText This is text that is separated by commas. The text is then unescaped. An array of items is created.
load_singleTextType Load text that has a type attribute. Each text of different type attributes will be handled independantly in as a hash entry. If no type attribute is supplied then the typeDefaults types will be used. A line can have multiple types. In the case where multiple types have the same value _alias indicators are created. The preferred type is stored in _pref
load_singleBinary Not done as I don’t have example data yet.


For technical support please email to ... for faster service please include Net::vFile and help in your subject line.


 Jay J. Lawrence -
 Infonium Inc., Canada


Copyright (c) 2003 Jay J. Lawrence, Infonium Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.


 Net::iCal - whose loading code inspired me for mine


RFC 2426, Net::iCal
Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 NET::VFILE (3) 2003-04-15

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.