constructor in Perl with an array(OOPS)
Posted
by superstar
on Stack Overflow
See other posts from Stack Overflow
or by superstar
Published on 2010-04-01T18:17:52Z
Indexed on
2010/04/01
18:23 UTC
Read the original article
Hit count: 471
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
© Stack Overflow or respective owner