unlink ($_) or &error(1,"Unable to open file: $_"); sub error { open the log and print out stuff (including $!) if the first variable is 1, exit the script (die style) if the first variable is 0, return to where you were (warn style) }