Kurt Kepshire threw 6 1/3 perfect innings before yielding five hits and needing ninth-inning relief help as the Cardinals beat the Pittsburgh Pirates, 3-1, yesterday in St. Louis in the first game of a doubleheader.

Ozzie Smith drew a bases-loaded walk with two out in the 12th inning of the nightcap as the Cardinals won, 4-3.

The sweep moved the Cardinals into a first-place tie with the New York Mets in the National League East.

In the second game, Tito Landrum opened the 12th with a double off Cecilio Guante (3-5) and went to third on a fly by Tom Herr. Jack Clark and Andy Van Slyke were intentionally walked. After Larry McWilliam replaced Guante, pinch hitter Brian Harper forced Landrum at the plate. Smith then walked on four pitches.

Darrell Porter's two-run single was the key hit for the Cardinals in the opener.

Kepshire (9-6), who started the day with a 4.50 earned run average, retired the first 19 batters he faced en route to his second victory since July 14.

The Pirates loaded the bases in the ninth on singles by pinch hitter Lee Mazzilli, Joe Orsulak and Johnny Ray. Jeff Lahti relieved and forced Bill Madlock to ground into a double play. Jason Thompson's infield single off Ken Dayley scored Orsulak, then pinch hitter Sixto Lezcano flied out to center to end the game.