in reply to Building a package for distribution: How do the pros do it?
In short, use $? only after using some function that sets it; see each particular function for details. $! is more generally applicable to any function taken from the C library that may set an error code.