[!
package test::object ;
sub id
{
my $self = shift ;
return "id $self->{n}" ;
}
sub name
{
my $self = shift ;
return "name $self->{n}" ;
}
sub new
{
my $class = shift ;
my $n = shift ;
my $self = {n=>$n} ;
bless $self, $class ;
return $self ;
}
!]
[-
$obj[0] = test::object->new (0) ;
$obj[1] = test::object->new (1) ;
$obj[2] = test::object->new (2) ;
$obj[3] = test::object->new (3) ;
-]