Australia, chasing a challenging 413 for victory, were bundled out for 183 after lunch as Sri Lanka, who won their last series against the visitors in 1999, took an unassailable 2-0 lead in the three-match rubber.
Veteran spinner Rangana Herath set up the win for the hosts with his maiden Test hat-trick which helped dismiss Australia for a record low of 106 in their first innings.
Overnight batsmen David Warner and skipper Steven Smith offered some resistance with their 51-run fourth wicket partnership but both of them fell to Perera's guile.
Warner, who tried to counter attack during his 31-ball 41, was trapped lbw off a straighter Perera delivery that hit the batsman on the front pad.
More From This Section
Smith (30), who used his feet well against the spinners during his 58-ball stay, was the next to go as he gave away a catch at backward short leg.
But it was Herath's left-arm spin that did the early damage in a match dominated by Sri Lankan slow bowlers.
Herath and Perera shared four wickets between them on a chaotic second day which saw the fall of 21 wickets and put the match on the fast track.
Australia's pace spearhead Mitchell Starc though made his presence felt on a track that offered little help to the fast bowlers with his career-best match figures of 11-94.