I suspect the reason is fundamentally the same. I missed that you have references among the values of %default_values, meaning that you need a deep copy (not the shallow copy originally proposed). Try this quick fix (just to confirm the hypothesis):
Ultimately, my preferred code for this would be something likemy %default = %default_values; # shallow copy $default{ AUTHOR } = +{ %{ $default_values{ AUTHOR } } }; # copy next level my $self = ref($class) ? bless( \%default, ref($class) ) : bless( \%default, $class );
where deep_copy takes a reference as argument and returns a reference to a deep copy of it.my $self = bless deep_copy( \%default_values ), $class;
I know that there are CPAN modules for doing deep copying, but I have no direct experience with any of them, so I can't recommend any one in particular. Maybe some other monk can.
the lowliest monk
In reply to Re^3: Wrong Error Message When Testing for Failure of Constructor
by tlm
in thread Wrong Error Message When Testing for Failure of Constructor
by jkeenan1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |