When Michael Begler and Jack Amiel were in their mid-20s, the writing partners got their first television script produced, an episode of the sitcom “Herman’s Head.” It was so low-budget that for a Caribbean island scene, Begler recalls, “when the characters are sitting on the beach, instead of sand, they used beige carpeting.”

The duo managed to write episodes for and land producing roles on other comedies like “Empty Nest” and “The Jeff Foxworthy Show,” before segueing into feature films, mostly of the formulaic family and rom-com variety. “Finally I said, ‘Can we do something just for ourselves?’ ” Begler says.

Begler and Amiel shifted gears when they created the critically acclaimed dark drama “The Knick.” That success led them recently to an overall deal at HBO and an offer to take over as showrunners for the network’s 2020 hit, the latest reinvention of “Perry Mason.” The noirish series, executive produced by Robert Downey Jr., stars Matthew Rhys in the title role, along with Juliet Rylance as Della Street, Chris Chalk as Paul Drake and Justin Kirk as Hamilton Burger.

“Having to push and reinvent ourselves has gotten us to this,” Begler said by phone recently while discussing the new season, which debuts Monday. This interview has been edited for length and clarity.

Q How did this opportunity come about?

A We were working on a spinoff of “The Knick” for HBO, which, fingers crossed, will see the light of day. They called us and said, “We’re looking for someone to possibly step in on ‘Perry Mason.’ ” We spoke to Team Downey and got along well and to Matthew Rhys, Juliet Rylance and Chris Chalk and felt there could be something here.

Then we went and did the historical research and thought, “There’s so much fun stuff here.” Jack and I love doing the research. It’s so much fun to dive into these worlds and discover how we can use what we find.

Q Do you think about cultural reference points with an L.A. setting? When Perry is talking to the judge about lawlessness and greed in Los Angeles, I thought Perry might get his nose split open in the next scene, a la “Chinatown.”

A The cultural references are just inside us. Before starting, I watched probably a hundred noir films on the Criterion. Some of that influence comes through. But with “Chinatown,” we consciously tried to go away from that. Still, it’s inevitable because it’s L.A. ’30s noir. Robert Downey Jr. said to me, “The season has a Robert Towne vibe,” and I said, “I’ll take that compliment.”

Q Was it tricky coming onto an existing show?

A “The Knick” was our creation and we knew what we wanted. Here, we’re coming into an established world and it was intimidating because the bar was set so high. When we took the gig, I was so scared. Like Perry, I had imposter syndrome. I didn’t think we could do it and thought we were in over our heads. It literally drove me back to therapy.

But inside, I knew we’ve reinvented ourselves so many times we could push ourselves and figure it out. We just had to put our heads down and do the work.

We could put our own stamp on it but really wanted to honor and respect and defer to Team Downey and HBO on this because it was theirs, not ours. For me, to have that humility coming in is important. I wanted to make sure we got it right. Then we could say, how do we elevate it?

Q What did you learn from watching the first season?

A The mandate was do it and do it better. We studied the first season, especially Perry, Della and Paul, and looked at what wasn’t there in the characters and in the storytelling. We felt we could expand the size of the story and what you see of Los Angeles. The first season was very gritty and dark and we wanted a little more sunshine in there.

We also wanted to dig deeper emotionally in the characters — our instinct was following them home, going into Paul’s world in the Black community, giving Della a more adult relationship and keep mining the hauntings of Perry.

Q You mentioned letting more light in. It felt like there’s more humor this year, too.

A We try to find the humor in things. When shows get too serious, we’re a little turned off; if a show doesn’t look at that side of human beings, it becomes exhausting.