Left-hander Perera reached his century after a 164-run stand for the first wicket with Dilshan, who became only the 11th batsman and the fourth Sri Lankan to compile 10,000 one-day runs.
Skipper Angelo Mathews hammered an unbeaten 70 and Milinda Siriwardana clubbed 52 not out off 26 balls as Sri Lanka plundered 136 runs in the last 11 overs to record their highest total against Pakistan.
The previous best by the Islanders against Pakistan was 349-9 in Singapore in 1996.
The match in Hambantota holds only academic interest as Pakistan already enjoy an invincible 3-1 lead, but both sides will want to end the series on a winning note ahead of two Twenty20 internationals.
Perera, whose only other one-day ton came against Bangladesh last year, smashed nine boundaries and four sixes before he was run out in the 34th over.
The flamboyant Dilshan reached the 10,000-run landmark in his 319th match when he took a single off Shoaib Malik to move to 55, before he was run out for 62.
The 38-year-old now has 10,007 runs, joining compatriots Kumar Sangakkara, Sanath Jayasuriya and Mahela Jayawardene in a coveted list headed by Indian great Sachin Tendulkar, who had 18,426 ODI runs.
Mathews and Siriwardana added a brisk 114 off just 55 deliveries to complete Sri Lanka’s best batting display of the series.
The hosts made three changes from the last match, dropping sling-arm fast bowler Lasith Malinga, seamer Nuwan Pradeep and Sachith Pathirana.
They were replaced by off-spinner Sachithra Senanayake, all-rounder Thisara Perera and fast bowler Lahiru Gamage.
Pakistan retained the same team. -AFP