package Farm; use strict; use warnings; sub new { my $className = shift; my $self = { farmBirds => [], # initialisation not strictly required, # but good for documentation purposes... # ... }; bless $self, $className; return $self; } sub addFarmBirds { my $self = shift; push @{ $self->{farmBirds} }, @_; } sub getFarmBirds { my $self = shift; return @{ $self->{farmBirds} }; } 1;