Important note: you can still get the HPV vaccine even into your 40s.
You can also get it even if you have had HPV before because there are multiple strains and while it can't help you clear out HPV you already have, it can help prevent infection from other strains you don't have yet.