Hello Ekta,
I'm not sure if this is the correct way to do it, but you can implement a singleton like this:: package Singleton; eval { my $instance = {}; $instance->{TIME} = time(); $instance->{NAME} = "MyName"; bless ($instance, __PACKAGE__); } sub instance { return $instance; } sub name { my $self = shift; if (@_) { $self->{NAME} = shift } return $self->{NAME}; } sub creationTime { my $self = shift; if (@_) { $self->{TIME} = shift } return $self->{TIME}; } 1; The singleton can be accessed in a reference script via Singleton::instance (); I don't believe you can make any of the member variables private through it is possible to have private functions using anonymous blocks.. Hope this helps, Joe Ekta Agarwal <[EMAIL PROTECTED]>@listserv.ActiveState.com on 11/19/2002 02:53:17 Sent by: [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc: Subject: [Perl-unix-users] perl - Private Constructors - how do we do that. Hi, I was trying to write a singleton class in perl. It requires me to write a private constructor. Can anyone tell me if there is the concept of a private constructor in perl, and if so how do I go about doing it? Thanks Ekta Agarwal __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - Let the expert host your site http://webhosting.yahoo.com _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs