Perera blasts Sri Lanka to victory in first South Africa Test