#!/usr/bin/perl
use warnings;
@old=`cat $ARGV[0]`;
@new_default = `cat $ARGV[1]`;
sub check($)
{
$conf = $_[0];
foreach my $old_line (@old)
{
if($old_line =~ /^$conf=/ or $old_line =~ /^# $conf is not set/)
{
print $old_line;
return 1;
}
}
return 0;
}
$line_count = 0;
for($line_count = 0; $line_count <= $#new_default; $line_count ++)
{
my $find = 0;
$curr_line = $new_default[$line_count];
if($curr_line !~ /# CONFIG.* is not set/ and $curr_line !~ /^CONFIG.*=.*/ )
{
print $curr_line;
}
elsif($curr_line =~ /^(CONFIG_.*)=.*/)
{
$find = check($1);
if($find == 0)
{
print $curr_line;
}
}
elsif($curr_line =~ /^# (CONFIG_.*) is not set/)
{
$find = check($1);
if($find == 0)
{
print $curr_line;
}
}
}
阅读(2333) | 评论(0) | 转发(0) |