PITTSBURGH (AP) -- Matt Cain's mind drifted. He couldn't help it.
A year to the day after throwing the 22nd perfect game in baseball history, the San Francisco Giants ace didn't give up a hit through four innings on Thursday night against the Pittsburgh Pirates.
''I tried not to think about it but there was enough talk about it that I couldn't really tune out,'' Cain said.
A single by Pittsburgh's Garrett Jones leading off the bottom of the fifth rendered any discussion of Cain making history again moot, one of the few things that didn't go right for the Giants in a 10-0 romp.
Cain (5-3) struck out three and walked two over 6 2-3 innings.
''He had good command of all his pitches,'' San Francisco manager Bruce Bochy said. ''He's in a good place right now with his delivery and command. I like where he's at.''
Hunter Pence hit his 11th homer of the season, while Buster Posey, Gregor Blanco and Joaquin Arias had three hits apiece for San Francisco, which avoided a sweep by sending the Pirates to their worst loss of the year.
Not bad for a team missing injured stars Pablo Sandoval, Marco Scutaro and Angel Pagan, all of whom are on the disabled list.
''It's a great sign,'' Bochy said. ''We're missing three big bats. You hope guys pick it up and they have the last couple of games. Blanco had a big game. Really, a lot of guys had big games.''
Even if it wasn't required on a night Cain seemed to move past the inconsistent play that's dogged him over the first two months of the season.
The three-time All-Star has run hot and cold this season, getting off to a horrific start in April before going 4-0 in May. The Giants lost both of his starts this month, scoring all of one run in the process.
Given a healthy dose of support, Cain didn't let it go to waste.
''I am throwing the ball a whole lot better,'' he said. ''I'm trying to eliminate that big inning. I had done a good job of that for some years now but I've kind of had trouble with it this year. It's a matter of putting it in the past and getting guys out.''
San Francisco's outburst spoiled the return of Pittsburgh starter Charlie Morton (0-1), who was celebrating an anniversary of his own. The righthander underwent Tommy John surgery on his right elbow on June 14, 2012. Just short of a year later, he surrendered four runs on seven hits, striking out five and walking one. The right-hander also hit three batters while making his first major league start in 381 days.
''I wish it had gone better but I think I can take quite a few positives,'' Morton said.
The Giants didn't knock Morton around so much as chip away. San Francisco touched Morton for a run in each of the first two innings then added two more in the fifth before breaking things open with five runs in the sixth against reliever Mike Zagurski.
The romp was a welcome change for the defending World Series champions, who have struggled on the road. San Francisco came in just 4-12 in its last 16 games away from AT&T Park but had little trouble with Cain returning to form.
Cain tossed a one-hitter against the Pirates last season, the lone mistake being a fastball in the sixth inning that McDonald turned into a single. Two months later he retired all 27 batters he faced against the overmatched Astros.
He didn't overwhelm Pittsburgh this time, instead letting his defense do most of the work. Cain wasted little time between pitches and the Pirates could never seem to get comfortable.
''We saw the good Matt Cain tonight,'' Pirates manager Clint Hurdle said.
San Francisco certainly looked at ease, pushing the lead to 4-0 during a weird fifth inning. Zagurski hit Brandon Crawford with one out and Posey smacked a ground-rule double to the gap in left-center. Crawford would have easily scored if the ball hadn't hopped over the fence.
Things evened out when Pence hit a dribbler that turned into a rundown between third and home. Crawford smacked into Pittsburgh third baseman Pedro Alvarez during the chase, with home plate umpire Tim McClellan awarding Crawford home plate after ruling Alvarez impeded Crawford's path.
Andres Torres hit a sacrifice fly, but a potentially big inning came undone when a liner by Arias went right at Pence standing off second base. The San Francisco outfielder dove forward to avoid the ball only to have it deflect off his helmet.
Pence earned a bit of revenge the next inning when he smoked a 3-run homer off Zagurski and the rout was on.
NOTES: Scutaro is still in considerable pain after the pinky finger in his left hand was drilled by a pitch on Tuesday. Bochy said there is considerable swelling and isn't sure when Scutaro will play again ... The Giants begin a three-game series in Atlanta on Friday. Madison Bumgarner (5-4, 3.58) faces Atlanta's Kris Medlen (3-6, 2.87) ... San Francisco's Nick Noonan appeared to have his first major league home run in the ninth inning when he hit a ball to right-center. The call was overturned when replay showed the ball hit the top of the fence but did not go over.