Text::vCard::Node(3) Object for each node (line) of a vCard


use Text::vCard::Node;
my %data = (
'param' => {
'HOME,PREF' => 'undef',
'value' => ';;First work address - street;Work city;London;Work PostCode;CountryName',
my $node = Text::vCard::Node->new({
node_type => 'address', # Auto upper cased
fields => ['po_box','extended','street','city','region','post_code','country'],
data => \%data,


Package used by Text::vCard so that each element: ADR, N, TEL etc are objects.

You should not need to use this module directly, Text::vCard does it all for you.



  my $node = Text::vCard::Node->new({
    node_type => 'address', # Auto upper cased
    fields => \['po_box','extended','street','city','region','post_code','country'],
    data => \%data,


  # Get the value for a standard single value node 
  my $value = $node->value();
  # Or set the value
  $node->value('New value');


  # The fields supplied in the conf area also methods.  
  my $po_box = $node->po_box(); # if the node was an ADR.
  # Set the value.
  my $street = $node->street('73 Sesame Street');


Returns the type of the node itself, e.g. ADR.


  my @units = @{ $org_node->unit() };
  $org_node->unit( [ 'Division', 'Department', 'Sub-department' ] );

As ORG allows unlimited numbers of 'units' as well as and organisation 'name', this method is a specific case for accessing those values, they are always returned as an array reference, and should always be set as an array reference.


  my @types = $node->types();
  # or
  my $types = $node->types();

This method will return an array or an array ref depending on the calling context of types associated with the $node, undef is returned if there are no types.

All types returned are lower case.


  if ( $node->is_type($type) ) {
      # ...

Given a type (see types() for a list of those set) this method returns 1 if the $node is of that type or undef if it is not.


  if ( $node->is_pref() ) {
      print "Preferred node";

This method is the same as is_type (which can take a value of 'pref') but it specific to if it is the preferred node. This method is used to sort when returning lists of nodes.


  my @types = qw(home work);
  $address->add_types( \@types );

Add a type to an address, it can take a scalar or an array ref.


  my @types = qw(home work);
  $address->remove_types( \@types );

This method removes a type from an address, it can take a scalar or an array ref.

undef is returned when in scalar context and the type does not match, or when in array ref context and none of the types match, true is returned otherwise.


  my $group = $node->group();

If called without any arguments, this method returns the group name if a node belongs to a group. Otherwise undef is returned.

If an argument is supplied then this is set as the group name.

All group names are always lowercased.

For example, Apple Address book used 'itemN' to group it's custom X-AB... nodes with a TEL or ADR node.


NOTE: This method is deprecated and should not be used. It will be removed in a later version.

  my $value = $node->export_data();

This method returns the value string of a node. It is only needs to be called when exporting the information back out to ensure that it has not been altered.


Returns the node as a formatted string.


If a node has a param of 'quoted-printable' then the value is escaped (basically converting Hex return into \r\n as far as I can see).


Leo Lapworth, LLA[email protected] Eric Johnson (kablamo), github ~!at!~ iijo dot org