in reply to if value not matches replace it with other value
Please enclose your code with <code> and </code> tags for better readability.
The code below basically does what you need. You can change the if and print statements in according to your needs.
#!/usr/bin/perl my %hash; open FH, "master.cfg" or die $!; while (<FH>) { chomp; my ($k, $v) = split /=/; $hash{$k} = $v; } close FH; open FH1, "config1.cfg" or die $!; while (<FH1>) { chomp; my ($key1, $value1) = split /=/; if ( defined $hash{$key1} and $hash{$key1} ne $value1) { print "$key1=$value1\n"; } } close FH1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: if value not matches replace it with other value
by Laurent_R (Canon) on Dec 30, 2014 at 11:06 UTC |