Matthew Perry is recalling the moment that he had to drop out of "Don't Look Up" starring Leonardo DiCaprio and Meryl Streep after a medical scare "stopped" his heart for five minutes.

In his upcoming memoir, "Friends, Lovers, and the Big Terrible Thing," the 53-year-old actor recounts being in a rehabilitation facility in Switzerland while the movie was being filmed. According to his memoir, he wasn't able to fully give up his addiction, and lied to doctors about severe stomach pain so he would be prescribed hydrocodone.

"In fact, I was OK," Perry, 53, wrote, per the Rolling Stone. "It still felt like I was constantly doing a sit-up — so it was very uncomfortable — but it wasn’t pain."

The doctors felt that a "medical device" in his back, requiring surgery, would best help relieve the actor's pain, Perry said. 

Matthew Perry

Matthew Perry pulled out of Netflix's "Don't Look Up" after a medical emergency stopped his heart for five minutes. (Photo by Kevin Winter/Getty Images)

According to Perry, he took hydrocodone the night before the surgery and was given propofol for anesthesia during the surgery. This combination is what stopped his heart.

‘FRIENDS’ STAR MATTHEW PERRY ‘REALLY GRATEFUL’ FOR JENNIFER ANISTON'S SUPPORT AMID ADDICTION JOURNEY

"Don't Look Up" cast

Jennifer Lawrence, Leonardo DiCaprio, Meryl Streep, Jonah Hill, and Adam McKay attend the "Don't Look Up" world premiere in December.  (Photo by Dimitrios Kambouris)

CLICK HERE TO SIGN UP FOR THE ENTERTAINMENT NEWSLETTER

"I was given the shot at 11:00 a.m.," Perry wrote, according to the outlet. 

"I woke up eleven hours later in a different hospital. Apparently, the propofol had stopped my heart. For five minutes. It wasn’t a heart attack — I didn’t flatline — but nothing had been beating. I was told that some beefy Swiss guy really didn’t want the guy from ‘Friends’ dying on his table and did CPR on me for the full five minutes, beating and pounding my chest. If I hadn’t been on ‘Friends,’ would he have stopped at three minutes? Did ‘Friends’ save my life again?"

Matthew Perry from Friends

Matthew Perry has previously said he spent "probably $9 million" trying to get sober through the years. (David M. Benett)

Perry added: "He may have saved my life, but he also broke eight of my ribs."

The actor noted that he was in too much pain following the incident to return to the "Don’t Look Up" set. He wrote that this decision was "heartbreaking."

The outlet reported that the "Friends" star, who began portraying Chandler Bing on the popular sitcom when he was only 24 years old, was set to play a role as a republican journalist in "Don’t Look Up" before the health scare. He reportedly even shot a scene with Jonah Hill, but it did not make it into the film’s release.

Perry wrote in his memoir that the role in Adam McKay’s Netflix movie would have been the "biggest movie I’d gotten ever." His role was reportedly written into scenes with the legendary Streep.

CLICK HERE TO GET THE FOX NEWS APP

His memoir, "Friends, Lovers and the Big Terrible Thing," releases on Nov. 1. The star has been promoting his upcoming book over the past several weeks. In an interview with the New York Times on Sunday, he revealed he spent $9 million trying to get sober.

Perry discussed his decades-long battle with drinking and drugs in his first memoir.