in reply to Re^2: Wrong Error Message When Testing for Failure of Constructor
in thread Wrong Error Message When Testing for Failure of Constructor
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Wrong Error Message When Testing for Failure of Constructor
by jkeenan1 (Deacon) on Jul 23, 2005 at 00:02 UTC | |
by tlm (Prior) on Jul 24, 2005 at 01:22 UTC | |
by jkeenan1 (Deacon) on Jul 24, 2005 at 01:40 UTC | |
|
Re^4: Wrong Error Message When Testing for Failure of Constructor
by jkeenan1 (Deacon) on Jul 22, 2005 at 19:45 UTC |