in reply to Perl search and replace

You could probably use a look-ahead and anchor the the beginning of the line.

perl -pi.BAK -e 's{^(?=Defaults\s+(?:env_reset|requiretty))}{#}'

I hope this is helpful.

Cheers,

JohnGG