>>>>> "CF" == Christoph Friedrich <christ...@christophfriedrich.de> writes:
CF> I have searched the internet but didn't found a good answer. CF> How do I clone a Perl Object? CF> For example like this: CF> $a = My::Object->new(); CF> $b = $a->clone(); the answer is you can't in the general case. only the class should be able to clone an object as it knows the implementation. you can't just do a deep copy if it is implemented with inside out objects or other stuff that won't allow external code to inspect it. the only solutions are use a class that supports its own cloning method or get all the data out of the object with accessor calls and construct a new object from that. and i bet you really don't need this but you just think you do. explain what your bigger problem is and with what particular classes. cloning isn't a general need in most designs. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/