http://www.perlmonks.org?node_id=905819

austin43 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am trying to figure out how to automatically search and comment out specific lines within the /etc/sudoers file. I have the following lines to change...
Defaults env_reset Defaults requiretty
I need them to look like...
#Defaults env_reset #Defaults requiretty
I tried the following lines of code in backticks...
`perl -pi -e 's/.+Defaults env_reset.+/ #Defaults env_reset/g' /etc/sudoers` `perl -pi -e 's/.+Defaults requiretty.+/ #Defaults requiretty/g' /etc/sudoers`
The ".+" is to match any number of characters before or after the phrase. I think I may be using it wrong, but I am not sure. Any thoughts or ideas are greatly appreciated. Thanks in advance!