Matthew Perry know’s he’s very lucky to be alive.

The “Friends” star, who is best known for his role as Chandler Bing in the beloved ’90s TV series, is speaking out about his three decades-long battle with alcohol and drug addiction in his upcoming memoir Friends, Lovers, and the Big Terrible Thing.

Back in 2018, Perry was hospitalized after suffering a gastrointestinal perforation, the public heard at the time.

However, it’s since been revealed that he’d been left fighting for his life for weeks after his colon burst from opioid overuse, with him spending two weeks in a coma and five months in the hospital. He had to use a colostomy bag for nine months.

Perry tells People, “The doctors told my family that I had a 2 percent chance to live. I’m grateful to be alive.

 “I was put on a thing called an ECMO machine, which does all the breathing for your heart and your lungs. And that’s called a Hail Mary. No one survives that.”

Elsewhere in the interview, Perry talks about nabbing the role of Chandler on “Friends” at age 24 when his alcohol addiction was just surfacing.

He tells the mag, “I could handle it, kind of. But by the time I was 34, I was really entrenched in a lot of trouble.”

READ MORE: Matthew Perry Confirms He’s Finished Writing His New Memoir

The publication points out that at one point, Perry was taking 55 Vicodin a day and weighed 128 lbs.

“I didn’t know how to stop,” the actor admits.

He says, “If the police came over to my house and said, ‘If you drink tonight, we’re going to take you to jail,’ I’d start packing. I couldn’t stop because the disease and the addiction is progressive. So it gets worse and worse as you grow older.”

Perry praises his “Friends” castmates for how they dealt with it all, sharing: “They were understanding, and they were patient. It could be said that [doing the show] saved me.”

READ MORE: Courteney Cox Says ‘Friends’ Co-Star Matthew Perry Is ‘Doing Great Now’

The star, who has been to rehab 15 times over the years, says of how he is now: “I’m pretty healthy now,” joking, “I’ve got to not go to the gym much more, because I don’t want to only be able to play superheroes. But no, I’m a pretty healthy guy right now.”

Not disclosing how long he’s currently been sober for, Perry goes on to say that he has “a lot of reminders to stay sober” by looking down at his scars from the 14 surgeries he’s had on his stomach.

He says, “My therapist said, ‘The next time you think about taking Oxycontin, just think about having a colostomy bag for the rest of your life.’ And a little window opened and I crawled through it and I no longer want Oxycontin anymore.”

The new issue of People hits newsstands Friday.