1 # $Id: Clone.pm,v 0.31 2009/01/20 04:54:37 ray Exp $
6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD);
12 @ISA = qw(Exporter DynaLoader);
13 # Items to export into callers namespace by default. Note: do not export
14 # names by default without a very good reason. Use EXPORT_OK instead.
15 # Do not simply export all your public functions/methods/constants.
17 @EXPORT_OK = qw( clone );
21 bootstrap Clone $VERSION;
23 # Preloaded methods go here.
25 # Autoload methods go after =cut, and are processed by the autosplit program.
32 Clone - recursively copy Perl datatypes
38 push @Foo::ISA, 'Clone';
47 $a = { 'foo' => 'bar', 'move' => 'zig' };
48 $b = [ 'alpha', 'beta', 'gamma', 'vlissides' ];
57 This module provides a clone() method which makes recursive
58 copies of nested hash, array, scalar and reference types,
59 including tied variables and objects.
62 clone() takes a scalar argument and an optional parameter that
63 can be used to limit the depth of the copy. To duplicate lists,
64 arrays or hashes, pass them in by reference. e.g.
66 my $copy = clone (\@array);
70 my %copy = %{ clone (\%hash) };
73 For a slower, but more flexible solution see Storable's dclone().
77 Ray Finch, rdf@cpan.org
79 Copyright 2001 Ray Finch.
81 This module is free software; you can redistribute it and/or
82 modify it under the same terms as Perl itself.