Section 31. No person compelled to testify in any proceedings under section thirty shall be liable to criminal prosecution for any matters or causes in respect of which he shall be examined or to which his testimony shall relate, except to prosecution for perjury committed in such testimony.