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

NAME

6       Clone - recursively copy Perl datatypes
7

SYNOPSIS

9         use Clone;
10
11         push @Foo::ISA, 'Clone';
12
13         $a = new Foo;
14         $b = $a->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 = new Foo();
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 an optional parameter that can be
34       used to limit the depth of the copy. To duplicate lists, arrays or
35       hashes, pass them in by reference. e.g.
36
37           my $copy = clone (\@array);
38
39           # or
40
41           my %copy = %{ clone (\%hash) };
42
43       For a slower, but more flexible solution see Storable's dclone().
44

AUTHOR

46       Ray Finch, rdf@cpan.org
47
48       Copyright 2001 Ray Finch.
49
50       This module is free software; you can redistribute it and/or modify it
51       under the same terms as Perl itself.
52

SEE ALSO

54       Storable(3).
55
56
57
58perl v5.12.0                      2009-01-20                          Clone(3)
Impressum