I know that there are many Sudoku solver over the internet.
But than I has no chance of learning perl and learn some of the algorhytms ^^

Shlomi Fish schrieb:
Hi Christoph!

On Monday 28 Dec 2009 13:11:17 Christoph Friedrich wrote:
My Big Problem is that I must copy an object to do a backtracking method
(I am going to develop a sudoku solver).


Well, you can always deep copy the object state, if you are sure it is self-
contained. (Using Storable's dclone() or whatever.). Moreover, I should note that there are plenty of Sudoku solvers around, including on CPAN:

http://search.cpan.org/search?query=sudoku&mode=all

And elsewhere:

http://www.google.com/search?q=sudoku%20solver

http://www.google.com/search?hl=en&q=sudoku+solver+open+source&aq=f&oq=&aqi=g1

Please consider re-using one of them.

Regards,

        Shlomi Fish

Uri Guttman schrieb:
"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


Reply via email to