http://qs321.pair.com?node_id=701826

Boldra has asked for the wisdom of the Perl Monks concerning the following question:

Hello readers,

Is there an easier way to unbless an object than this?
package Liftable; use Class:ISA; sub new { bless $_[1], $_[0] } sub lift { my $self = shift; my $old_class = ( grep { $_ !~ /__PACKAGE__/ } ( Class::ISA::super_path( ref($self) ) ) )[0]; bless $self, $old_class; }
I want to temporarily make an object a member of a second (third, fourth) class, overriding some methods, but retaining all attributes when the object reverts. I'm worried that the solution above might have unwanted side-effects.


- Boldra