eval { while(CONDITION) { die if SOMETHING; die if SOMETHING_ELSE; ... } }; if(not $EVAL_ERROR) { # loop finished on it's own accord }