From the moment Luke Perry first appeared as Dylan McKay on “Beverly Hills, 90210,” he felt like the perfect pop song: You couldn’t believe you’d ever lived in a world where you hadn’t known of him. His impossibly chiseled cheekbones, throwback pompadour, sideburns and perpetual squint made every scene he was in look iconic. He spoke French, read Lord Byron for fun and surfed.

Dylan was an erotic awakening for millions of the teenagers watching, including me. Perry, who died at age 52 this week, didn’t invent this soulful bad-boy — or even the look that came with it. James Dean did that. But Perry did originate the teen soap version of James Dean that became a trope for decades to come, a spirit guiding each successive generation to long for the smart, troubled boy from a broken home who just needed a little love and understanding to coax him out of his always-beautiful shell: 90210’s Dylan gave way to “Dawson’s Creek’s” Pacey, “The O.C.’s” Ryan and “Gossip Girl’s” Chuck. These edgy boys were always meant to contrast with the ostensible leading boys, the good guys: Perpetual savior Brandon on “90210,” earnest Dawson of the “Creek,” nerdcore Seth on “The O.C.,” confoundingly hot-but-dull Dan on “Gossip Girl.”

While we all pretended to look for our Brandons, we were really pining for Dylans.

At least I was. For the first few decades of my romantic life, I toggled in an embarrassingly obvious way between these two archetypes. Dylan and his descendants taught me there were good boys and bad boys — and the one you chose reflected your values. I identified as an Andrea Zuckerman-style overachiever and believed I should want a Brandon (Jason Priestley), not a Dylan.

Characters on “90210” were always whispering Dylan was such trouble: In his first episode, Brenda repeats a rumor that he’d gotten a French girl pregnant. This was not what any of us were supposed to want. It would take me decades to realize this wasn’t just a trope, but a trap. And calling Dylan the “bad boy” was as much a check on female libidinous urges as it was a satisfying archetype.

My first truly serious relationship began my senior year of high school in 1991 — smack in the middle of “90210” mania — with a boy named Dave who was nearly a Brandon impersonator: People often told him he looked like Priestley. He had the perfectly feathered hair, equally impressive cheekbones, preppy clothes, and he worked on the school newspaper staff with me. He was a respectful, smart boy who would never pressure me to have sex.

What I didn’t know at the time was he was closeted, like most gay teenage boys in the 1990s. Of course he identified with Brandon; he literally looked like him, and he was a good boy like him. But when I asked him about “90210” this week, Dave told me he’d always crushed on Dylan. Sure, Dylan was pretty, he said, but he was more than that. Dylan gave Dave, a closeted boy fearful of being gay-bashed, the feeling that, in a different world where Dave might’ve come out in high school, Dylan would be the one to stand up for him in the face of a homophobic attack. This quality was a pillar of Dylan’s character: In his first scene on the show, he emerges from a dark corner to chase off two meatheads harassing a nerd in the computer room.

For a time, I believed I was a Brandon girl. But all I really wanted was a Dylan. See, this was the real secret of “90210′s” Brandon-Dylan dichotomy: Dylan wasn’t much of a “bad boy” on paper; he swooped in to defend nerds! He only became “bad” when Perry’s sex appeal collided with a character whose parents were never around. The “bad” came from all of us watching and lusting, imagining ourselves in that parent-free hotel suite he lived in.

After Dave and I broke up, I chose another Brandon — though this one was heterosexual, which complicated matters a bit. I nearly married him. Once I emerged from the wreckage of that fantasy-perfect life — the one where I marry my Brandon, who has been given the gift of my virginity — my unsatisfied desire for a Dylan came back in full force.

With the clarity of hindsight, I see my subsequent single life was an obstacle course full of ersatz Dylans, some of whom looked laughably similar to Luke Perry. I ran in literary circles in New York City at this time, and Brooklyn was churning out Dylans at an alarming rate. They were everywhere, always ready to talk about Byron, invite you to a reading, or explain why Bukowski isn’t as terrifyingly sexist as you think he is. They were damaged, of course, and so they were blameless for what they were about to do to you emotionally.

They knew how to lean on tropes, too.

When you get past a certain age and into the deep stages of relationships, you realize Brandons don’t keep you safe, and Dylans can be as vulnerable and complex as they are dangerous. Teen shows appear to be growing up a little as well in these times of fractured audiences and inclusive story lines. The delightfully sex-positive British show “Sex Education” has no reason to set up such a good/bad dichotomy to warn girls away from sexy boys. “Riverdale,” the teen-noir take on “Archie,” is too concerned with murders to worry about whether Archie and Jughead are sweet good boys or tempting bad boys. The show is, if anything, deliberately blurring these archetypes: With his newspaper ways, Jughead fits into the classic mold of teen nerd, but he also enjoys a robust sex life and dabbles in a motorcycle gang. Archie seems nice but ends up in prison. It’s all very complicated.

Perry played a key part in this new landscape of sophisticated teen shows, playing Archie’s dad on “Riverdale.” His presence is meant as a meta-joke, placing him alongside other teen idols of the past playing adults now — Molly Ringwald and Skeet Ulrich among them. It’s also meant as an homage, and a chance to show us how much more complex Dylan McKay might be as an adult. Perry’s take on Fred Andrews was multifaceted: He’s sexy, caring, fatherly and sometimes heroic. But he’s not above having an affair or getting entangled in some backroom deals. It worked because Perry knew what he was doing.

Perry appeared to have known what he was doing with Dylan McKay, too, or at least he appreciated the gravity in retrospect. In a 2008 interview he said: “I’m going to be linked with him until I die, but that’s actually just fine. I created Dylan McKay. He’s mine.”

He’s right. Perry is the key to Dylan rising from a throwaway character on a forgotten show to a classic character on a show that defined its era. But Dylan also transcended Perry precisely because of how great he was.

Through relationships past and present, Dylan is all of ours, too.