Skip Menu |

This queue is for tickets about the Clone-PP CPAN distribution.

Report information
The Basics
Id: 18261
Status: open
Priority: 0/
Queue: Clone-PP

People
Owner: Nobody in particular
Requestors: keith [...] iveys.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.02
Fixed in: (no value)



Subject: Doesn't work if class overrides stringification
I was trying to use this to clone a WWW::Mechanize object, but all the contained URI objects end up being copied shallowly because the URI class overrides stringification and so doesn't give anything like URI=HASH(0x9fa6380) for the regex to parse.
This patch should fix it.
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);