perladdicted has asked for the wisdom of the Perl Monks concerning the following question:
==============#!/usr/bin/perl open FH, "master.cfg" or die $!; open FH1, "config1.cfg" or die $!; while(my $line=<FH>){ chomp; my %hash; (my $key,my $value) = split /=/, $line; $hash{$key} = $value; while(my $line2=<FH1>){ chomp; my %hash1; (my $key1,my $value1) = split /=/, $line; $hash1{$key} = $value; open FH1, ">config1_new.cfg" or die $!; if ($value1 != $value)
OUTPUT:[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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: if value not matches replace it with other value
by pme (Monsignor) on Dec 30, 2014 at 08:56 UTC | |
by Laurent_R (Canon) on Dec 30, 2014 at 11:06 UTC |