Skipper Mathews struck an all-important century as he put up a solid resistance after Sri Lanka were reeling at 135 for four at lunch, and along with Perera, who hit a half-century, kept the hosts' chances in the match alive.
The two shared a 135-run stand for the sixth wicket but Perera (70, 106b, 11X4) fell just before the tea break to give the visitors a much needed breakthrough.
At tea, Mathews was batting on 110 (237b, 13X4) and Rangana Herath was on three.
Starting at 134 for five after lunch, Mathews and Perera looked to play an attacking game and it worked well for them. While the skipper was solid at one end, the debutant wicketkeeper-batsman looked to go on the offensive.
Also Read
With the pitch easing out and India rotating their bowlers in short spells, the two batsmen made merry at the crease.
Their 50-run partnership came off only 85 balls as Sri Lanka crossed the 100-mark.
On their part, the Indian bowlers didn't lose control of their line and length, with runs not coming too quickly for their discomfort.
But the partnership started to flourish as time passed and Mathews-Perera put on 100 runs off 186 balls. Perera scored his second half-century of the match, reaching there off 89 balls. Although, it was Mathews, who was the star of the day, reaching his second consecutive hundred in the series off 217 balls.
The batsman threw his hard work away, going for a reverse sweep and hitting straight to Rohit Sharma at point, four overs before tea.