diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2002-12-02 23:36:58 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2002-12-02 23:36:58 +0000 |
commit | f13d6e7d9e9fc11a04dabab5cb86486aaec500c6 (patch) | |
tree | 635c3748060297e46f510096be77b1ebe1289b0a /perl-install/network | |
parent | ad9f5530fc680a154f87283652a676a259c62935 (diff) | |
download | drakx-f13d6e7d9e9fc11a04dabab5cb86486aaec500c6.tar drakx-f13d6e7d9e9fc11a04dabab5cb86486aaec500c6.tar.gz drakx-f13d6e7d9e9fc11a04dabab5cb86486aaec500c6.tar.bz2 drakx-f13d6e7d9e9fc11a04dabab5cb86486aaec500c6.tar.xz drakx-f13d6e7d9e9fc11a04dabab5cb86486aaec500c6.zip |
(add2hosts): use output and pixelization
Diffstat (limited to 'perl-install/network')
-rw-r--r-- | perl-install/network/network.pm | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index 14a4fdaf3..2f20d131a 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -143,28 +143,15 @@ sub write_interface_conf { sub add2hosts { my ($file, $hostname, @ips) = @_; - my %l; - $l{$_} = $hostname foreach @ips; - foreach (cat_($file)) { - m/\s*(\S+)(.*)/; - my ($ip, $host) = ($1, $2); - $l{$ip} ||= $host if $host !~ /^\s*$hostname\s*$/; - } + my %l = map { if_(/\s*(\S+)(.*)/, $1 => $2) } + grep { !/\s+\Q$hostname\E\s*$/ } cat_($file); + + my $sub_hostname = $hostname =~ /(.*?)\./ ? " $1" : ''; + $l{$_} = "\t\t$hostname$sub_hostname" foreach grep { $_ } @ips; + log::l("writing host information to $file"); - local *F; - open F, ">$file" or die "cannot write $file: $!"; - while (my ($ip, $v) = each %l) { - $ip or next; - print F $ip; - if ($v =~ /^\s/) { - print F $v; - } else { - print F "\t\t$v"; - print F " $1" if $v =~ /(.*?)\./; - } - print F "\n"; - } + output($file, map { "$_$l{$_}\n" } keys %l); } # The interface/gateway needs to be configured before this will work! |