Don't even think of it. This expression is used as a wish that what was just mentioned will never happen. For example, He's going to give another speech? Perish the thought!
This phrase appeared in Handel's oratorio Joshua
(1748; text by Thomas Morell): “It never shall be said that our allies in vain implor'd our aid. Perish the thought!” Also see god forbid