Ultrafast frequency-agile terahertz devices using methylammonium lead halide perovskites