I have a package which I wanted to make an object, so I had something
like the following:
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self;
$self->{BOOL_1} = 0;
$self->{BOOL_2} = 0;
# etc...
while (shift) {
$self->{$_} = 1;
}
bless $self, $class;
}
The above code wouldn't work unless I did the following:
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {
BOOL_1 => 0,
BOOL_2 => 0,
#etc...
};
bless $self, $class;
while (shift) {
$self->{$_} = 1;
}
}
I then got undefined errors unless I added a bless $self, $class;
to the last line of the function. Is there an easier way to set options
within an object's constructor?
-Dan
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]