When it shall appear probable to a court of record, having general jurisdiction, that a person who has testified in an action or proceeding before it has committed perjury in any testimony so given, it may, by order or process for that purpose, immediately commit the person to prison, or take a recognizance for the person’s appearance to answer to an indictment for perjury. In such case, if the court shall deem that any paper or document produced by either party is necessary to be used in the prosecution for perjury, it may detain the same, and direct it to be delivered to the county attorney.