Perera bags hat-trick in Sri Lankan win
Pakistan were strongly placed at 166-2 in the 38th over before they collapsed to 199 all out chasing a 244-run target in the day-night contest, with man-of-the-match Perera finishing with 4-42.
Opener Azhar Ali carried his bat through the innings with an unbeaten 81, hitting one six and four boundaries. He added 113 for the third wicket with skipper Misbah-ul-Haq (57).
Pakistan lost their last eight wickets for 33 runs, with six batsmen failing to open their account in the innings.
Kumar Sangakkara earlier top-scored with a 130-ball 97 for Sri Lanka, who now lead 2-1 in the five-match series. Pakistan won the opening one-dayer by six wickets and Sri Lanka won the second game by 76 runs in Pallekele.
The third match in Colombo was abandoned due to rain on Wednesday.
Perera had Younis Khan caught behind and then had Shahid Afridi caught in the covers before completing the hat-trick with the wicket of Sarfraz Ahmed, caught by skipper Mahela Jayawardene in the slips.
"Thisara is improving and learning with each game," said Jayawardene.
"Also Kumar batted really well. We are still short of our best game, but we'll take this."
Perera also ran out Sohail Tanvir in the same over and then ended the innings with the wicket of Saeed Ajmal.
Pakistan's slide began with the dismissal of Misbah, with Nuwan Kulasekara taking a brilliant catch to his right at mid-off off paceman Lasith Malinga.
Malinga also dismissed Mohammad Hafeez with his fifth delivery and left-arm spinner Sajeewa Weerakoon trapped Asad Shafiq (25) leg-before for his maiden wicket in one-day internationals.
"Everything was under control and I don't know what happened after that. And we can't drop players like Sangakkara," said Misbah.
Sangakkara, who had a lucky escape when he was dropped on 35 by Umar Gul off leg-spinner Afridi, cracked three sixes and seven fours in his impressive knock.
He went for big shots after completing the half-century, scoring his last 47 runs off just 31 balls. He looked set to reach his 14th one-day hundred before he was caught by Azhar Ali in the deep off spinner Ajmal.
He added 110 for the fourth wicket with Jayawardene, who hit four boundaries in his 50-ball 40 before being bowled by paceman Tanvir.
Pakistan had put in a disciplined bowling performance as they restricted Sri Lanka to 125 off 35 overs before Sangakkara and Jayawardene stepped up the run-rate and helped their team score 118 in the last 15 overs.
Off-spinners Mohammad Hafeez and Ajmal, and Tanvir each took two wickets.
Sangakkara also added 55 runs for the second wicket with Tillakaratne Dilshan (24) after opener Upul Tharanga (four) fell in the third over, caught by Younis at second slip off Gul.
Hafeez broke the second-wicket stand when he trapped Dilshan leg-before with his first delivery and then bowled Dinesh Chandimal (18) just before the rain stopped play.