The tragic last hours before Friends actor Matthew Perry died from a drug overdose have been laid bare in new court documents.