All-optical THz wave switching based on CH3NH3PbI3 perovskites