The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 19
Clone.pm 3433
Clone.xs 33
MANIFEST 01
META.json 22
META.yml 22
Makefile.PL 11
README 067
t/08fieldhash.t 00
t/dump.pl 32
10 files changed (This is a version diff) 46120
@@ -1,7 +1,15 @@
 Revision history for Perl module Clone
 
+0.37 2014-05-15 16:45:33  garu
+  - removed Carp dependency (GARU)
+  - silenced some clang warnings (JACQUESG)
+  - added a README (GARU)
+
+0.36 2013-12-07 17:36:04  garu
+  - fixed compilation issue on AIX and C89 (GAAS)
+
 0.35 2013-09-05 13:26:54  garu
-  - SV's can be NULL (shit happens) (fixes RT86217) (Tux)
+  - SV's can be NULL (shit happens) (fixes RT86217) (HMBRAND)
   - making tests compatible with older versions of Test::More (GARU)
 
 0.34 2012-12-09 14:46:09  garu
@@ -1,28 +1,20 @@
 package Clone;
 
 use strict;
-use Carp;
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD);
 
 require Exporter;
 require DynaLoader;
 require AutoLoader;
 
-@ISA = qw(Exporter DynaLoader);
-# Items to export into callers namespace by default. Note: do not export
-# names by default without a very good reason. Use EXPORT_OK instead.
-# Do not simply export all your public functions/methods/constants.
-@EXPORT = qw();
+@ISA       = qw(Exporter DynaLoader);
+@EXPORT    = qw();
 @EXPORT_OK = qw( clone );
 
-$VERSION = '0.35';
+$VERSION = '0.37';
 
 bootstrap Clone $VERSION;
 
-# Preloaded methods go here.
-
-# Autoload methods go after =cut, and are processed by the autosplit program.
-
 1;
 __END__
 
@@ -32,35 +24,42 @@ Clone - recursively copy Perl datatypes
 
 =head1 SYNOPSIS
 
-  package Foo;
-  use parent 'Clone';
+    use Clone 'clone';
+
+    my $data = {
+       set => [ 1 .. 50 ],
+       foo => {
+           answer => 42,
+           object => SomeObject->new,
+       },
+    };
+
+    my $cloned_data = clone($data);
 
-  package main;
-  my $original = Foo->new;
-  $copy = $original->clone;
-  
-  # or
+    $cloned_data->{foo}{answer} = 1;
+    print $cloned_data->{foo}{answer};  # '1'
+    print $data->{foo}{answer};         # '42'
 
-  use Clone qw(clone);
-  
-  $a = { 'foo' => 'bar', 'move' => 'zig' };
-  $b = [ 'alpha', 'beta', 'gamma', 'vlissides' ];
-  $c = Foo->new;
+You can also add it to your class:
 
-  $d = clone($a);
-  $e = clone($b);
-  $f = clone($c);
+    package Foo;
+    use parent 'Clone';
+    sub new { bless {}, shift }
+
+    package main;
+
+    my $obj = Foo->new;
+    my $copy = $obj->clone;
 
 =head1 DESCRIPTION
 
-This module provides a clone() method which makes recursive
-copies of nested hash, array, scalar and reference types, 
+This module provides a C<clone()> method which makes recursive
+copies of nested hash, array, scalar and reference types,
 including tied variables and objects.
 
-
-clone() takes a scalar argument and duplicates it. To duplicate lists,
+C<clone()> takes a scalar argument and duplicates it. To duplicate lists,
 arrays or hashes, pass them in by reference. e.g.
-    
+
     my $copy = clone (\@array);
 
     # or
@@ -69,15 +68,15 @@ arrays or hashes, pass them in by reference. e.g.
 
 =head1 SEE ALSO
 
-L<Storable>'s dclone() is a flexible solution for cloning variables,
+L<Storable>'s C<dclone()> is a flexible solution for cloning variables,
 albeit slower for average-sized data structures. Simple
 and naive benchmarks show that Clone is faster for data structures
-with 3 or less levels, while dclone() can be faster for structures
+with 3 or less levels, while C<dclone()> can be faster for structures
 4 or more levels deep.
 
 =head1 COPYRIGHT
 
-Copyright 2001-2012 Ray Finch. All Rights Reserved.
+Copyright 2001-2014 Ray Finch. All Rights Reserved.
 
 This module is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself.
@@ -45,7 +45,7 @@ hv_clone (SV * ref, SV * target, HV* hseen, int depth)
   TRACEME(("ref = 0x%x(%d)\n", ref, SvREFCNT(ref)));
 
   hv_iterinit (self);
-  while (next = hv_iternext (self))
+  while ((next = hv_iternext (self)))
     {
       SV *key = hv_iterkeysv (next);
       TRACEME(("clone item %s\n", SvPV_nolen(key) ));
@@ -122,6 +122,7 @@ sv_clone (SV * ref, HV* hseen, int depth)
   SV *clone = ref;
   SV **seen = NULL;
   UV visible;
+  int magic_ref = 0;
 
   if (!ref)
     {
@@ -136,7 +137,6 @@ sv_clone (SV * ref, HV* hseen, int depth)
 #else
   visible = (SvREFCNT(ref) > 1) || (SvMAGICAL(ref) && mg_find(ref, '<'));
 #endif
-  int magic_ref = 0;
 
   TRACEME(("ref = 0x%x(%d)\n", ref, SvREFCNT(ref)));
 
@@ -278,7 +278,7 @@ sv_clone (SV * ref, HV* hseen, int depth)
                  mg->mg_len);
       }
       /* major kludge - why does the vtable for a qr type need to be null? */
-      if ( mg = mg_find(clone, 'r') )
+      if ( (mg = mg_find(clone, 'r')) )
         mg->mg_virtual = (MGVTBL *) NULL;
     }
     /* 2: HASH/ARRAY  - (with 'internal' elements) */
@@ -4,6 +4,7 @@ Clone.xs
 Makefile.PL
 MANIFEST
 META.yml			Module meta-data (added by MakeMaker)
+README
 t/01array.t
 t/02hash.t
 t/03scalar.t
@@ -4,7 +4,7 @@
       "Ray Finch <rdf@cpan.org>"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.120921",
+   "generated_by" : "ExtUtils::MakeMaker version 6.94, CPAN::Meta::Converter version 2.120351",
    "license" : [
       "perl_5"
    ],
@@ -46,5 +46,5 @@
          "url" : "http://github.com/garu/Clone"
       }
    },
-   "version" : "0.35"
+   "version" : "0.37"
 }
@@ -7,7 +7,7 @@ build_requires:
 configure_requires:
   ExtUtils::MakeMaker: 0
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.120921'
+generated_by: 'ExtUtils::MakeMaker version 6.94, CPAN::Meta::Converter version 2.120351'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -22,4 +22,4 @@ resources:
   bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Clone
   license: http://dev.perl.org/licenses/
   repository: http://github.com/garu/Clone
-version: 0.35
+version: 0.37
@@ -8,7 +8,7 @@ WriteMakefile(
     'LICENSE'       => 'perl',
     'PL_FILES'      => {},
     'BUILD_REQUIRES' => {
-      'Test::More'            => 0,
+      'Test::More' => 0,
     },
     'LIBS'          => [''],     # e.g., '-lm'
     'DEFINE'        => '',       # e.g., '-DHAVE_SOMETHING'
@@ -0,0 +1,67 @@
+Clone - recursively copy Perl datatypes
+=======================================
+
+This module provides a ```clone()``` method which makes recursive
+copies of nested hash, array, scalar and reference types,
+including tied variables and objects.
+
+```perl
+    use Clone;
+
+    my $data = {
+       set => [ 1 .. 50 ],
+       foo => {
+           answer => 42,
+       },
+    };
+
+    my $cloned_data = clone($data);
+
+    $cloned_data->{foo}{answer} = 1;
+    print $cloned_data->{foo}{answer};  # '1'
+    print $data->{foo}{answer};         # '42'
+```
+
+You can also add it to your class:
+
+```perl
+    package Foo;
+    use parent 'Clone';
+
+    package main;
+
+    my $obj = Foo->new;
+    my $copy = $obj->clone;
+```
+
+```clone()``` takes a scalar argument and duplicates it. To duplicate lists,
+arrays or hashes, pass them in by reference. e.g.
+
+```perl
+    my $copy = clone (\@array);
+
+    # or
+
+    my %copy = %{ clone (\%hash) };
+```
+
+
+See Also
+--------
+
+[Storable](https://metacpan.org/pod/Storable)'s ```dclone()``` is a flexible solution for cloning variables,
+albeit slower for average-sized data structures. Simple
+and naive benchmarks show that Clone is faster for data structures
+with 3 or less levels, while ```dclone()``` can be faster for structures
+4 or more levels deep.
+
+
+COPYRIGHT
+---------
+
+Copyright 2001-2014 Ray Finch. All Rights Reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+
diff --git a/var/tmp/source/GARU/Clone-0.35/Clone-0.35/t/08fieldhash.t b/var/tmp/source/GARU/Clone-0.37/Clone-0.37/t/08fieldhash.t
old mode 100644
new mode 100755
@@ -17,7 +17,6 @@ sub ok {
 }
 
 package dump;
-use Carp;
 
 %dump = (
 	'SCALAR'	=> 'dump_scalar',
@@ -30,7 +29,7 @@ use Carp;
 # Given an object, dump its transitive data closure
 sub main'dump {
 	my ($object) = @_;
-	croak "Not a reference!" unless ref($object);
+	die "Not a reference!" unless ref($object);
 	local %dumped;
 	local %object;
 	local $count = 0;
@@ -78,7 +77,7 @@ sub recursive_dump {
 	# If the referenced was blessed, we bless it once the object is dumped.
 	# The retrieval code will perform the same on the last object retrieved.
 
-	croak "Unknown simple type '$ref'" unless defined $dump{$ref};
+	die "Unknown simple type '$ref'" unless defined $dump{$ref};
 
 	&{$dump{$ref}}($object);	# Dump object
 	&bless($bless) if $bless;	# Mark it as blessed, if necessary