Which one of the following two sentences is correct?
When you were young you ought to learn good habits.
When you were young you ought to have learnt good habits.
To me none of the sentences sound correct because both of them(ought to, ought to have) indicate present tense but the sentences is framed in the past tense.