How 'Thor: Ragnarok' screenwriter (and former pizza guy) Eric Pearson became Marvel's go-to script doctor

He was just about to give up the dream.

It was 2010, and Eric Pearson had spent the past eight years working menial gig after menial gig — from pizza delivery guy to messenger to ticket-taker at an arthouse theater in West Hollywood, the closest the aspiring screenwriter could get to the film industry. He’d just turned 30, and he was about to leave Los Angeles, tail tucked firmly between his legs, for a flight of shame back to his native Boston.

“It was close, man,” Pearson told Yahoo Entertainment last week at a coffee shop in Beverly Hills, on the day Thor: Ragnarok, the first movie for which he’s been the central writer, opened across the world. “I bet I could’ve floated for another three to six months, but I was on the verge of the embarrassing move home to the parents. It was just so hard. It’s expensive to live out here, and there’s only so long you can hide your credit-card debts.”

Pearson, who’d already given up his dream of becoming an actor (“I was just bad, I know it now, too, and I probably even knew it then,” he laughed) and studied screenwriting at New York University’s Tisch School for the Arts, had one last shot to escape the unsustainable clutches of the minimum wage. He had applied to the Marvel Writer’s Program, the elite training workshop that the burgeoning movie studio, fresh off Phase One megahits like Iron Man and The Incredible Hulk, created in 2009 to groom in-house talent.

It was an exhaustive process. First, applicants had to choose one of three “lower-tier” Marvel Comics characters and pitch a movie around them. His options were Eternals, Cloak and Dagger, and Ares (Marvel’s version of the god of war). “And I tried to overcompensate. I was like, ‘I’ve got two!’ I built one for Ares and one for Cloak and Dagger. And they’re like, ‘You’re misunderstanding how to impress us. Just give us one good thing.‘”

So Pearson zeroed in on Cloak and Dagger, formulated his premise, and then pitched … and pitched … and pitched. “It took forever,” he said. Or, precisely, seven meetings before he got into a room with Kevin Feige, Marvel’s ballcap-sporting studio boss and the architect of the studio’s $12-billion blockbuster machine. An hour later, he was offered a slot in the program.

Pearson will tell you he’s not even the most fervent of fanboys. He can tell you where he fell in love with comics (Newbury Comics) and the first ones he bought (an Iron Man with War Machine on the cover, and two Thors — including, coincidentally, a “mega-spectacular” for $4.50 that opened with Loki pretending to be Odin on the throne and Thor locked in hell with Mephisto, a premise that will sound familiar to anyone who’s seen Ragnarok). But he admits he had a Phase None in high school, when he opted to spend his cash on gas instead, before reengaging with splash pages in his twenties as Watchmen and The Dark Knight Returns hit stands. (Now he’s very particular about what he follows, but begs you not to sleep on Saga and Sex Criminals.)

Suddenly, he was a hired gun on the Marvel payroll, doing anything the studio asked of him — and doing it on overdrive. “I think because I had struggled for so long and was so broke, I think my attitude was to just put my head down and work really hard on anything I did,” he recalled. “I think a lot people might have said, ‘Oh, I’m in this, now I’ll talk to my agent about parlaying this into what the next thing might be.'”

Instead, Pearson begged for more work, and was eventually asked to script a series of Marvel One Shot webisodes, including The Consultant, Item 47, and A Funny Thing Happened on the Way to Thor’s Hammer.

Even though the shoots were only two or three days long, they gave him practical experience and got him noticed. “You’ve got all the toys and the bells and the whistles there, and great actors.” It also helped that two of the One Shots he wrote were directed by the studio’s co-president, Louis D’Esposito. Pearson could feel himself becoming part of the family, and his stature within it was growing: “I was kind of like the little cousin for a long time, and then it was like, ‘Oh, no, we can trust Eric to know the world, and supply a lot of material, too.” When he heard they might do another One Shot, he came into the office with five eight-page scripts for other characters they could produce a short around.

He eventually became a writer and story editor for Marvel Television’s Agent Carter, where he stayed for two years. In 2014, he was brought on to do rewrites on Ant-Man, during difficult times for both Marvel and Pearson. Marvel was in the process of breaking up with writer-director Edgar Wright (who was ultimately replaced by Peyton Reed), and Pearson was in the process of breaking up with his girlfriend. “It was a good time to be in Marvel 12 to 14 hours a day and be focused on work,” he said. “There were a bunch of notes that needed to be done, and they said do them all. … I think I reminded them that I could get them 30 pages in a day … when they’re in an emergency situation.”

Pearson’s favorite contributions to Ant-Man include the scene in the strip club and Stan Lee’s “Crazy stupid fine” cameo. “And I also love taking credit for shrinking the guy who doesn’t support him and flushing down the toilet,” he said. “My mom hates that, and I love it.”

In retrospect, Pearson looks at Ant-Man as an audition for the threequel Thor: Ragnarok, which he took over from screenwriting duo Craig Kyle and Christopher Yost and engineered what was essentially a Page 1 rewrite. He spent most of the production of Ragnarok on the ground in Australia, where he met his future wife, Kate, and has since chipped in with uncredited pre-production and post-production work on Spider-Man: Homecoming, Avengers: Infinity War, and the untitled fourth Avengers clash.

It took only seven years — which could still feel like an eternity if you’re living in a high-priced metropolis with a low-paying job and no semblance of a career — but with Ragnarok on its way to blockbuster status, Pearson is clearly making good company among Marvel’s most prized wordsmiths.

In other words, he won’t ever have to deliver pizza again.

Thor: Ragnarok is currently in theaters.

Watch: Mark Ruffalo on how he gave voice, and body, to Hulk in ‘Ragnarok’:

Read more from Yahoo Entertainment: