Khan scores 177 as Perera takes five wickets
Pakistan cricketer Younis Khan (R) celebrates with teammate Sarfraz Ahmed after scoring 150 runs on the second day of the opening Test match against Sri Lanka in Galle on August 7, 2014 - by Ishara S.Kodikara
Resuming after lunch on 347-5, the tourists made use of the easy-paced wicket to build a challenging total, with veteran Younis Khan top-scoring with 177.
Khan, who came in to bat at 19-2 on the first morning and ended the day on 133, anchored the innings with the help of lower-order batsmen.
The 36-year-old, who is playing his 90th Test, batted for eight hours and 16 minutes, hitting 15 boundaries and a six in his 24th Test century.
Khan's vigil came to an end soon after lunch when he flicked Perera to Kithuruwan Vithanage at short mid-wicket, a soft dismissal that came against the run of play.
Pakistan's wicket-keeper Sarfraz Ahmed made 55 and shared a sixth-wicket stand of 66 with Khan when he lobbed an easy catch to mid-on to give Perera his second wicket.
The off-spinner had Saeed Ajmal and Junaid Khan caught at leg-slip by Mahela Jayawardene, taking the retiring former Sri Lankan captain's tally to 202 Test catches.
Only India's Rahul Dravid has taken more catches (210) by a fielder other than a wicket-keeper.
Tailender Abdur Rehman, essentially a left-arm spinner, showed his batting skills by hammering six fours and a six while making 50, his second Test half-century.
Pakistan, who resumed at their overnight score of 261-4, went to lunch on 347-5 with Asad Shafiq making 75 during a fifth-wicket stand of 137 with Khan.
The visitors added 32 runs in the first hour when left-arm spinner Rangana Herath broke through for Sri Lanka by trapping Shafiq leg-before. The batsman's appeal to the TV umpire went in vain.
Sri Lanka came close to removing Khan when he was on 156, but seamer Shaminda Eranga spilled a sharp return catch as the batsman failed to keep a drive along the ground.