diff -ru Clone-PP-1.02/PP.pm Clone-PP-new/PP.pm
--- Clone-PP-1.02/PP.pm 2003-08-28 14:06:40.000000000 -0400
+++ Clone-PP-new/PP.pm 2006-03-20 16:42:48.000000000 -0500
@@ -35,9 +35,13 @@
# Extract both the structure type and the class name of referent
my $class_name;
- if ( "$source" =~ /^\Q$ref_type\E\=([A-Z]+)\(0x[0-9a-f]+\)$/ ) {
+ if ( eval { $source->isa($ref_type) } ) {
$class_name = $ref_type;
- $ref_type = $1;
+ for my $type ( qw( HASH ARRAY SCALAR CODE REF GLOB LVALUE ) ) {
+ next unless UNIVERSAL::isa($source, $type);
+ $ref_type = $type;
+ last;
+ }
# Some objects would prefer to clone themselves; check for clone_self().
return $CloneCache{ $source } = $source->$CloneSelfMethod()
if $source->can($CloneSelfMethod);