END { local $?; # preserve previous return code # do anything } # now, outside of the END block, # $? refers to the global and the # program officially terminates # using this value.