The pair finished off what Mahela Jayawardene (100) and Angelo Mathews (44) had started after Sri Lanka had been reduced to 51 for four by the World Cup debutants as they chased 233 for victory. Full World Cup Schedule
Jayawardene had appeared to have the outcome in control for Sri Lanka with his 19th ODI century and a 126-run partnership with Mathews but when he became Hamid Hassan's third wicket with 55 runs needed, the momentum shifted back towards Afghanistan.
World Cup Photos
Perera, an aggressive lower-order batsmen, then took the game away with some big hitting and finished on 47 as his side made 236-6 with 10 balls to spare. Mendis was nine not out. Afghanistan had been dismissed for 232 in 49.4 overs, which was not considered enough of a target to defend on the small University Oval ground and good pitch that tends to get easier to bat on as the day progresses.
Their bowlers, however, started like they felt it would be sufficient with both Lahiru Thirimanne and Tillakaratne Dilshan dismissed for golden ducks, while Kumar Sangakkara was bowled by Hassan for seven. Hassan struck again in the 12th over when Dimuth Karunaratne was well caught by Nawroz Mangal at first slip for 23, which reduced the 1996 World Cup champions to 51-4.
Afghanistan's batsmen had not looked out of their depth, though they did show a lack of experience at the highest level when they were unable to capitalise on good starts. Asghar Stanikzai top scored with 54, his fifth one-day international half century, but he was also guilty of getting out when he should have settled down to bat through until the end of the innings.
Stanikzai had combined with Samiullah Shenwari (38) in an 88-run partnership and the pair appeared so comfortable they looked to have set a platform for their side to eventually push on towards a total approaching 300.
However, the wheels fell off when Stanikzai was caught in the deep by Mendis, a dismissal that appeared to slam the brakes on the batting side's momentum. Shenwari went shortly after and it was left to captain Mohammad Nabi and Najibullah Zadran to rebuild the innings and set themselves to launch in the final 15 overs.
Both fell in the batting power play bowled by Lasith Malinga and Suranga Lakmal, who turned the screw by conceding just 10 runs in the five overs.
The pair finished off what Mahela Jayawardene (100) and Angelo Mathews (44) had started after Sri Lanka had been reduced to 51 for four by the World Cup debutants as they chased 233 for victory.
Full World Cup Schedule