1Tree::DeepClone(3)    User Contributed Perl Documentation   Tree::DeepClone(3)
2
3
4

NAME

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

SYNOPSIS

9               #!/usr/bin/env perl
10
11               use 5.010;
12               use strict;
13               use warnings FATAL => 'all';
14
15               use Tree::DeepClone;
16
17               # -----------------------
18
19               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/);
20               my($tree)     = Tree::DeepClone -> new('root');
21
22               $tree -> add_child({}, map {Tree::DeepClone -> new($_)} 1..3);
23
24               my($value);
25
26               say 'Tree:';
27
28               for ($tree -> traverse)
29               {
30                       $value = $_ -> value;
31
32                       $_ -> meta({$value => ($value eq 'root') ? '0' : $alphabet[$value - 1]});
33
34                       say $_ -> value, '. meta: ', ${$_ -> meta}{$value};
35               }
36
37               my($clone) = $tree -> clone;
38
39               say 'Clone:';
40
41               for ($clone -> traverse)
42               {
43                       $value = $_ -> value;
44
45                       say $_ -> value, '. meta: ', ${$_ -> meta}{$value};
46               }
47

DESCRIPTION

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

METHODS

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

SUPPORT

57       <https://github.com/ronsavage/Tree>.
58

ACKNOWLEDGEMENTS

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

AUTHOR

63       Ron Savage <rsavage@cpan.org>.
64
65       <https://savage.net.au/>.
66
68       This library is free software; you can redistribute it and/or modify it
69       under the same terms as Perl itself.
70
71
72
73perl v5.38.0                      2023-07-26                Tree::DeepClone(3)
Impressum