Matt Cain might just end up being worth every penny. The highest-paid right-hander in baseball history flirted with on-field history Friday, taking a perfect game deep into a 5-0 victory over the Pittsburgh Pirates. Cain retired the first 17 hitters he faced in the Giants' home opener and finished with a one-hitter. Pirates pitcher James McDonald scuttled Cain's bid for the first perfect game in Giants history with a sixth-inning single. "I was definitely aware of it," Cain said of the perfect game bid. "He put a good swing on it. He did his job." Cain did his the rest of the way. McDonald was the first and only Pirates base runner, but he hit his liner to left field just hard enough to keep Cain from accomplishing a lifelong goal of throwing a perfect game. "I'm always kind of conscious of it," he said. "I've never had one." Cain has had three one-hitters in his Giants career. This might have been his best -- he struck out 11, one short of his career high. "We've all seen him locked in like this, but this was as good as he's been," manager Bruce Bochy said. "He had all his pitches working." Cain was given plenty of run support for a second straight start, and Buster Posey made sure some of it came in dramatic fashion. In his first official at-bat at AT&T Park since the devastating home-plate collision last May 25, Posey doubled off the center-field wall to bring Melky Cabrera home in the first inning. Posey scored a batter later on a single by Aubrey Huff. "Buster smashed that ball," Bochy said. "That helps guys settle down. They're hyped up and they want to put on a show for the fans."