my $object = My::Class->new(); while (my $value = eval { $object->next_val() } ) { if ($@) { print "Error: $@\n"; next(); } # do cool stuff }