Perera dismissed Haris Sohail (ten), Shan Masood (21) and Babar Azam (nought) to leave Pakistan in tatters on 62-5 at dinner after they were set a tough target of 317 to win.