in reply to Re: if value not matches replace it with other value
in thread if value not matches replace it with other value

Please note that your syntax for opening files works, but is somewhat obsolete. It is better to use the three-argument syntax and to use lexical filehandles. Something like this:
my $infile = "master.cfg"; open my $FH, "<", $infile or die "could not open $infile $!";
You of course have to adapt other places of your code where you use the filehandles (to use $FH instead of FH).