while($i < 20000000) { @objects = getObjects(); foreach my $obj (@objects) { SomeMethod($obj); } $i += 100; } sub SomeMethod { my $obj = shift; AnotherMethod($obj); } sub AnotherMethod { my $obj = shift; } #### -------------------------------- package Obj; sub new { my $class = shift; my $name = shift; my $arrayRef = shift; my $self = { NAME => $obj, ARRAY_REF => $arrayRef }; bless $self, $class; return $self; } return 1; # ex: my $obj = new Obj("x", \@arrayOfObjects);