Yes, but only if you have the necessary levels that would be needed to unlock the perk naturally. For example, nerdy glasses will raise your intelligence from 2 to 4, as long as you're level 20, allowing you to buy the first lvl of hammer & forge without having to invest those 2 points in intelligence first.
As soon as you take off the glasses, your int stat drops back to 2, and the associated perks will be deactivated until your intelligence is high enough again.