Subject: | Set::Scalar blesses unblessed refs |
Hi,
I seem to have uncovered a bit of a bug in Set::Scalar::Base. The _strval subroutine will rebless unblessed objects.
Here's a way to reproduce the error.
my $x = new Set::Scalar( [] ) ;
print $_ , "\n" foreach $x->members ;
You'll notice that the output is ARRAY=ARRAY(0x893ebd4) instead of just ARRAY(0x893ebd4). I suggest the following alternative.
use Scalar::Util ;
sub _strval {
my $class = ref $_[0];
return $_[0] unless $class;
return sprintf("%s(%x)",
$class,
Scalar::Util::refaddr($_[0])
);
}
This subroutine has been tested, and appears to work. The only drawback that I can think of is that data will not be serializable between diferent versions of Set::Scalar. If you want to be more creative, you can probably force backwards compatibility.
Thanks,
Josh