scholarship.law.upenn.edu/cgi/viewconten…
First, as with any claim of entrapment, the claim of a perjury trap is an affirmative defense that thus has to be proven by a defendant.
Second, the perjury trap requires a showing that the perjurious testimony was procured improperly by the government.