has 'id' => ( is =>'ro', isa => 'Int', required => 1, builder => '_labelling', init_arg => undef, ); sub _labelling { $N++ } has 'verlet' => ( is =>'rw', isa => 'ArrayRef[Molecule::Atom]', required => 1, weak_ref => 1, default => sub { [] }, ); sub add_verlet{ my $self = shift; print $self->{id},"\n"; my $array = $self->{verlet}; foreach my $obj (@_){ print "adding :", $obj->{id},"\n"; push(@{$array},$obj); weaken(@{$array}[-1]); } print "Array dim = $#{$array}\n"; } sub print_verlet{ my $self = shift; my $array = $self->{verlet}; print "Verlet from Atom ", $self->{id}, "\n"; foreach my $obj (@{$array}){ print "Verlet list :", $obj->{id},"---->\n"; } }