Clone reviews

RSS | Module Info

Clone (0.24) *****

Clone is, quite frankly, a brilliant module.

I mean, if you want to copy a data structure or something, it doesn't get any better than a single function that can be used as an importable function, non-imported function, or a method, that is fast as hell, acts as only a single debugger statement, and takes up only 13K of memory!

What more could you possibly want? For most uses, it's basically copies in zero time using zero resources, or so close to it, who cares.

However, there is one major caveat. If you are cloning object trees and such, you need to know if Clone will work with the object's classes properly.

For a number of classes, particularly the more complex ones, they cannot be trivially cloned, and require the intervention of things like the Storable hooks.

Because Clone is very naive in this regard, it may not be useful in all cases.

However, if you start by using Clone, it's quite trivial to replace it with Storable::dclone instead. And for people WRITING modules that need Storable hooks or have non-trivial cloning issues, Clone can be used to provide the intial naive clone very very fast, after which you then to the relevant cleaning up.

Clone (0.20) *****

Extension to add a 'clone' function to distinct copies of perl data-types. Written in XS, so quite, the module largely works very well. It messes up with DBI DBD handles (provoking "Can't call prepare method on handle DBI::db=HASH(0x25755c8) after take_imp_data()"), but when that is solved, it would be nice to have Clone as a core module.

Clone (0.18) ***

This module is almost great. I've implemented some classes and needed to add "cloning" ability. Rather than write complicated recursive cloning functions (which I started doing....) I found Clone. It was as simple as adding

use Clone 'clone'

to the code to add a clone method to the class, and it seems to work with no problems.

But minus one star because it doesn't make use of any serialization hooks like Storable does. So for certain kinds of objects, clone just doesn't work. Minus another star because the documentation does not reflect this, aside from a recommendation to use Storable's dclone for slower but more reliable cloning.

Since Storable is a core module now, I'd just assume use that instead.