++ed by:
POTATOGIM

1 PAUSE user

Ron Savage
and 1 contributors

NAME

Tree::DeepClone - A subclass of Tree::Fast which does deep cloning

SYNOPSIS

        #!/usr/bin/env perl

        use 5.010;
        use strict;
        use warnings FATAL => 'all';

        use Tree::DeepClone;

        # -----------------------

        my(@alphabet) = (qw/a b c d e f g h i j k l m n o p q r s t u v w x y z/);
        my($tree)     = Tree::DeepClone -> new('root');

        $tree -> add_child({}, map {Tree::DeepClone -> new($_)} 1..3);

        my($value);

        say 'Tree:';

        for ($tree -> traverse)
        {
                $value = $_ -> value;

                $_ -> meta({$value => ($value eq 'root') ? '0' : $alphabet[$value - 1]});

                say $_ -> value, '. meta: ', ${$_ -> meta}{$value};
        }

        my($clone) = $tree -> clone;

        say 'Clone:';

        for ($clone -> traverse)
        {
                $value = $_ -> value;

                say $_ -> value, '. meta: ', ${$_ -> meta}{$value};
        }

DESCRIPTION

This module simply adds deep cloning to Tree::Fast. As per the Synopsis, you must use Tree::DeepClone everywhere you want this feature.

METHODS

All methods in <Tree::Fast> are available in Tree::DeepClone.

SUPPORT

https://github.com/ronsavage/Tree.

ACKNOWLEDGEMENTS

  • Stevan Little for writing Tree, upon which this module is based.

AUTHOR

Ron Savage <rsavage@cpan.org>.

https://savage.net.au/.

COPYRIGHT AND LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.