Concept:The perfect infinitive ("to have told") is used for past actions that should have been avoided.Explanation:The sentence refers to a past action: he told the secret, which he should not have done.The clause "but he did" confirms that the action is completed.Thus, the correct form is the perfect infinitive "to have told"."Ought not to tell" is present tense and does not fit the past context.Therefore, replace "tell" with "have told".Answer:B. have told