constructor in Perl with an array(OOPS)
- by superstar
whats the difference between these two 'new' constructors in perl?
1) sub new {
my $class = shift;
my $self = {};
$self->{firstName} = undef;
$self->{lastName} = undef;
$self->{PEERS} = [];
bless ($self, $class);
return $self;
}
2) sub new {
my $class = shift;
my $self = {
_firstName => shift,
_lastName => shift,
_ssn => shift,
};
bless $self, $class;
return $self;
}
I am using the 2nd one so far, but i need to implement the arrays in perl?
can you suggest a way to do it with the 2nd 'new' constructor