# try to open or die but not immediately open $file or go_away($file,$!); sub go_away { $file = shift; $error = shift; # tell the surfer something nice print $q->redirect($url_to_see_nicer_pages_than_500error); # now die and preserve my error log from being incomplete die(couldn't open $file: $error); }