
Putting/accessing an object from an array - help!
Here's the problem:
#!/usr/local/bin/perl -w
package Person;
use strict;
sub new
{
my $proto = shift();
my $class = ref($proto) || $proto;
my $self = {};
$self->{NAME} = undef;
$self->{AGE} = undef;
$self->{PEERS} = [];
bless($self, $class);
return $self;
Quote:
}
sub name
{
my $self = shift;
return $self->{NAME};
Quote:
}
sub age
{
my $self = shift;
return $self->{AGE};
Quote:
}
sub peers
{
my $self = shift;
Quote:
}
1; # package Person;
package main;
use strict;
my $me = Person->new();
$me->name("Asfand Yar");
$me->age(22);
$me->peers("Naz", "Amjad");
printf("%s is %d years old.\n", $i->name(), $i->age());
print("His peers are: ", join(", ", $i->peers()), "\n");
Quote:
}
And sorry for being so ignorant.
Asfand Yar
asfand at email.com