2010-11-12 09:09:48 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
my %cvar2line = ();
|
|
|
|
my @lines = ();
|
|
|
|
|
|
|
|
my $first = 1;
|
|
|
|
while(<>)
|
|
|
|
{
|
|
|
|
chomp;
|
|
|
|
s/\r//g;
|
2010-11-30 12:21:50 +00:00
|
|
|
s/\/\/.*//;
|
2010-11-12 09:09:48 +00:00
|
|
|
|
2010-11-30 12:21:50 +00:00
|
|
|
if(/^\s*(?:set\s+|seta\s+|)(\S+)/)
|
2010-11-12 09:09:48 +00:00
|
|
|
{
|
|
|
|
if(exists $cvar2line{$1})
|
|
|
|
{
|
|
|
|
$lines[$cvar2line{$1}] = $_;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$cvar2line{$1} = scalar @lines;
|
|
|
|
push @lines, $_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif($first) # only take comments, empty lines from the first config
|
|
|
|
{
|
|
|
|
push @lines, $_;
|
|
|
|
}
|
|
|
|
$first = 0
|
|
|
|
if eof;
|
|
|
|
}
|
|
|
|
|
|
|
|
print "$_\n" for @lines;
|