# phpman > man > Data::Grove::Parent(3pm)

## NAME
    [Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown) - provide parent properties to [Data::Grove](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove/markdown) objects

## SYNOPSIS
     use [Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown);

     $root = $object->root;
     $rootpath = $object->rootpath;
     $tied = $object->add_magic([ $parent ]);

     $node = [Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown)->new($hash [, $parent]);
     $node_list = [Data::Grove::ParentList](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParentList/markdown)->new($array [, $parent]);

## DESCRIPTION
    [Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown) is an extension to [Data::Grove](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove/markdown) that adds `"Parent"' and `"Raw"' properties
    to [Data::Grove](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove/markdown) objects and methods for returning the root node of a grove, a list of nodes
    between and including the root node and the current node, and a method that creates parented
    nodes.

    [Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown) works by creating a Perl ``tied'' object that contains a parent reference
    (`"Parent"') and a reference to the original [Data::Grove](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove/markdown) object (`"Raw"'). Tying-magic is used
    so that every time you reference the [Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown) object it actually references the
    underlying raw object.

    When you retrieve a list or a property of the Raw object, [Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown) automatically adds
    magic to the returned list or node. This means you only call `add_magic()' once to create the
    first [Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown) object and then use the grove objects like you normally would.

    The most obvious use of this is so you don't have to call a `"delete"' method when you want to
    release a grove or part of a grove; since [Data::Grove](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove/markdown) and [Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown) objects have no
    cyclic references, Perl can garbage collect them normally.

    A secondary use is to allow you to reuse grove or property set fragments in multiple trees.
    WARNING: [Data::Grove](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove/markdown) currently does not protect you from creating your own cyclic references!
    This could lead to infinite loops if you don't take care to avoid them.

## METHODS
    $object->root()
    $object->rootpath()
        `"root()"' returns the root node if `$object' is a `"[Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown)"' object.
        `"rootpath()"' returns an array of all the nodes between and including the root node and
        `$object'.

    $tied = $object->add_magic([ $parent ])
        `"add_magic()"' returns a "[Data::Grove::Parent](https://www.chedong.com/phpMan.php/perldoc/Data%3A%3AGrove%3A%3AParent/markdown)" object with `$object' as it's `"Raw"'
        object. If `$parent' is given, that becomes the tied object's parent object.

## AUTHOR
    Ken MacLeod, <ken@bitsko.slc.ut.us>

## SEE ALSO
### perl

