sub get_lock { local($0) = "(acquiring lock)"; flock(...); # returning restores previous value of $0 }