while( my $accnt = $allAccnt->next ) { $accnt->calcInterest() if $accnt->inCredit(); } #### sub calcInterest { my $self = shift; return unless $self->inCredit(); ... } #### $_->calcInterest() while $allAccnts->next;