sub foo { 5/$_[0]; } print "Before foo\n"; eval { foo 0; return 1; } or do { print "Oops!\n" }; print "Going onto other things\n"; #outputs Before foo Oops! Going onto other things