Knowledge as a bad thing
I have attempted to examine the Pali in this verse. The key word appears to be 'ñattaṃ', which is said to mean 'intellectual faculty' rather than good knowledge (Ñāṇa). 


  Ñatta
  (nt.) [nomen agentis from jānāti] the intellectual faculty,
  intelligence .


Therefore, this foolishness would not only apply to religion (such as religious people that seek worldly fame &amp; material benefits from religion) but also to the worldly intellect in general (such as scientists, politicians &amp; criminals that use their intellectual faculty to create harmful &amp; destructive things &amp; schemes).