I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-01-12 14:08:01-08 by jdhedden in response to 9699
Re: Generating thousands of objects
The POD contains a simplistic scheme for a singleton class. As written, its main deficiency is that the singleton object isn't reinitialized if the "new" method is called with different parameters.

If the class is truly singleton in the way you described, you could override _ID with your own :ID subroutine:
sub _id :ID { return 0; }
Be aware that you must guarantee that object destruction occurs before you create another object of such a class. Otherwise, destruction of the old object will wipe out the data of the new object.

Customizing the "new" method for each class based on its needs is a nice idea. Thanks. I'll look into it, but it will take some work.
Direct Responses: 9710 | Write a response