diff options
author | Olivier Blin <oblin@mandriva.org> | 2004-08-24 13:55:08 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2004-08-24 13:55:08 +0000 |
commit | 0eff3a74371c8a6647e5d06e79fbd055a41c7ada (patch) | |
tree | 6e0890b9072a1a2728dfa9d8c6ddf4bc4aef4edd | |
parent | 7c618bc6b5a11cf92edba042ef872eafe619dd8d (diff) | |
download | drakx-0eff3a74371c8a6647e5d06e79fbd055a41c7ada.tar drakx-0eff3a74371c8a6647e5d06e79fbd055a41c7ada.tar.gz drakx-0eff3a74371c8a6647e5d06e79fbd055a41c7ada.tar.bz2 drakx-0eff3a74371c8a6647e5d06e79fbd055a41c7ada.tar.xz drakx-0eff3a74371c8a6647e5d06e79fbd055a41c7ada.zip |
(add2hosts) make it more readable
-rw-r--r-- | perl-install/network/network.pm | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index 473535ae8..8f1898423 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -170,20 +170,18 @@ sub write_interface_conf { sub add2hosts { my ($file, $hostname, @ips) = @_; - my ($sub_hostname) = $hostname =~ /(.*?)\./; - my %l = map { - my ($ip, $space, $aliases) = /^\s*(\S+)(\s+)(\S+.*)/; - $aliases =~ s/(^|\s+)\Q$hostname\E(\s+|$)/$1/g; - $sub_hostname and $aliases =~ s/(^|\s+)\Q$sub_hostname\E(\s+|$)/$1/g; - if_($aliases !~ /^\s*$/, $ip => $space . $aliases) + + my %l; + foreach (cat_($file)) { + my ($ip, $aliases) = /^\s*(\S+)\s+(\S+.*)$/ or next; + push @{$l{$ip}}, grep { !member($_, $hostname, $sub_hostname) } split /\s+/, $aliases; } cat_($file); - $sub_hostname and $hostname = "$hostname $sub_hostname"; - $l{$_} .= ($l{$_} ? " " : "\t\t") . $hostname foreach grep { $_ } @ips; + push @{$l{$_}}, $hostname, if_($sub_hostname, $sub_hostname) foreach grep { $_ } @ips; log::explanations("writing host information to $file"); - output($file, map { "$_$l{$_}\n" } keys %l); + output($file, map { "$_\t\t" . join(" ", @{$l{$_}}) . "\n" } keys %l); } # The interface/gateway needs to be configured before this will work! |