#!/usr/bin/perl open FH, "master.cfg" or die $!; open FH1, "config1.cfg" or die $!; while(my $line=){ chomp; my %hash; (my $key,my $value) = split /=/, $line; $hash{$key} = $value; while(my $line2=){ chomp; my %hash1; (my $key1,my $value1) = split /=/, $line; $hash1{$key} = $value; open FH1, ">config1_new.cfg" or die $!; if ($value1 != $value) #### [root@localhost test]# cat master.cfg env=qa env_var2=val2 env_var1=val1 env_var3=val3 env_var4=val4 env_var5=val5 [root@localhost test]# cat config1.cfg env_var3=x env_var4=y Var=conf #### variavle=value env_var2=val2 env_var1=val1