my $object = My::Class->new(); while (my $value = $object->next_val() ) { # do cool stuff }