1Clone(3)              User Contributed Perl Documentation             Clone(3)
2
3
4

NAME

6       Clone - recursively copy Perl datatypes
7

SYNOPSIS

9         package Foo;
10         use parent 'Clone';
11
12         package main;
13         my $original = Foo->new;
14         $copy = $original->clone;
15
16         # or
17
18         use Clone qw(clone);
19
20         $a = { 'foo' => 'bar', 'move' => 'zig' };
21         $b = [ 'alpha', 'beta', 'gamma', 'vlissides' ];
22         $c = Foo->new;
23
24         $d = clone($a);
25         $e = clone($b);
26         $f = clone($c);
27

DESCRIPTION

29       This module provides a clone() method which makes recursive copies of
30       nested hash, array, scalar and reference types, including tied
31       variables and objects.
32
33       clone() takes a scalar argument and duplicates it. To duplicate lists,
34       arrays or hashes, pass them in by reference. e.g.
35
36           my $copy = clone (\@array);
37
38           # or
39
40           my %copy = %{ clone (\%hash) };
41

SEE ALSO

43       Storable's dclone() is a flexible solution for cloning variables,
44       albeit slower for average-sized data structures. Simple and naive
45       benchmarks show that Clone is faster for data structures with 3 or less
46       levels, while dclone() can be faster for structures 4 or more levels
47       deep.
48
50       Copyright 2001-2012 Ray Finch. All Rights Reserved.
51
52       This module is free software; you can redistribute it and/or modify it
53       under the same terms as Perl itself.
54

AUTHOR

56       Ray Finch "<rdf@cpan.org>"
57
58       Breno G. de Oliveira "<garu@cpan.org>" and Florian Ragwitz
59       "<rafl@debian.org>" perform routine maintenance releases since 2012.
60
61
62
63perl v5.16.3                      2012-12-09                          Clone(3)
Impressum