Tree::DeepClone - A subclass of Tree::Fast which does deep cloning
#!/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}; }
This module simply adds deep cloning to Tree::Fast. As per the Synopsis, you must use Tree::DeepClone everywhere you want this feature.
All methods in <Tree::Fast> are available in Tree::DeepClone.
https://github.com/ronsavage/Tree.
Stevan Little for writing Tree, upon which this module is based.
Ron Savage <rsavage@cpan.org>.
https://savage.net.au/.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tree, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tree
CPAN shell
perl -MCPAN -e shell install Tree
For more information on module installation, please visit the detailed CPAN module installation guide.