R
Ralph Moritz
Hi,
I've got some class data which I want to initialize once.
I was thinking of doing it like this:
{ package Foo;
my $FirstTime = 1;
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
$class->init() if ($FirstTime);
}
sub init {
# Initialize class data...
$FirstTime = 0;
}
}
Is this okay, or is there a generally accepted way
to do this?
Thanks,
Ralph
I've got some class data which I want to initialize once.
I was thinking of doing it like this:
{ package Foo;
my $FirstTime = 1;
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
$class->init() if ($FirstTime);
}
sub init {
# Initialize class data...
$FirstTime = 0;
}
}
Is this okay, or is there a generally accepted way
to do this?
Thanks,
Ralph