Perfect gerunds (having + past participle) allow you to show that one action happened before another, adding precision to your expression of time relationships between events.
Practice tip: Think about sequence: 'I regret having said that' = I said it first, then I regretted it. The gerund action always comes first.