in reply to object swizzling?
You can't turn the object referenced by $x into the object referenced by $z, except of course by assignment: $x=$z. You can however, rebless any reference into a new class:
use strict; use warnings; sub Eng::speak { print "I speak English\n"; } sub Fr::speak { print "Je parle francais\n"; } my $x=bless({},'Eng'); print "<$x>\n"; #prints: <Eng=HASH(0x814ec28)> $x->speak(); #prints: I speak English bless($x, 'Fr'); print "<$x>\n"; #prints: <Fr=HASH(0x814ec28)> $x->speak(); #prints: Je parle francais
As for proxy objects and lazy loading, there are numerous modules on CPAN for this purpose. See CPAN search: proxy object for starters.
Best, beth
|
|---|