How to replaces a value in a file after a particular string using perl?

view story

http://www.unix.com – I need to replace the value of notifications_enabled to 0 if the value already set to 1 and vice versa(not the other values and spaces remain same after the value changed). I tried the below program for that. Can any one help me out. file:test.cfg Code: define host {                   hostgroups                    linux-servers                   max_check_attempts            5             & (HowTos)