Fox

"Riverdale's" tribute to the late Luke Perry will feature a very special guest.

The Season 4 episode, which is scheduled to air October 9 on The CW, has enlisted Perry's friend and former "Beverly Hills, 90210" co-star Shannen Doherty.  Titled "In Memoriam," it will reflect on Perry's legacy and the imprint his character, Fred Andrews, had on the show.

Perry died in March at the age of 52 after suffering a major stroke.

Showrunner Roberto Aguirre-Sacasa announced the news at San Diego Comic-Con on Sunday. He described Doherty's role as "very emotional."

Perry and Doherty starred together on "90210" for four seasons. They renewed their friendship in 2015 when both were dealing with health issues.

Aguirre-Sacasa also revealed that he and Perry had been planning an appearance by Doherty for some time. It was "something that Luke wanted to happen since Season 1," he said.

"They were such good friends, and when we were putting together this tribute episode, we wanted to make it as special as possible, and so we asked Shannen to do a pivotal, super-emotional role. She read the script and immediately said yes. It’s very impactful."

Doherty is also starring in "BH90210," Fox's meta revival of the series. Most of the original cast — Jason Priestley, Jennie Garth, Ian Ziering, Gabrielle Carteris, Brian Austin Green and Tori Spelling — will play versions of themselves as they try to mount a revival of the teen soap.

Perry was not attached to the project, which was announced just before he died. "BH90210" will also honor Perry in some way.

For all of our San Diego Comic Con coverage, please click here!