summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-05-26 17:18:49 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2010-05-26 17:18:49 -0700
commitcbcbcc82fa7ba76715707f08ec20f1d2b5bbe9fa (patch)
treeaee68014cfe766b52d9ca501b6123707e64b826f
parent2fe081df156e90fb89b9bedaccb4b860709e1af3 (diff)
downloadvyatta-cfg-system-cbcbcc82fa7ba76715707f08ec20f1d2b5bbe9fa.tar.gz
vyatta-cfg-system-cbcbcc82fa7ba76715707f08ec20f1d2b5bbe9fa.zip
Fix use of bareword file handles
Rather than using BAREWORD file handles, use 3 arg open and local variable.
-rwxr-xr-xscripts/system/vyatta_update_resolv.pl32
1 files changed, 18 insertions, 14 deletions
diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl
index 7f2b84b2..42affd15 100755
--- a/scripts/system/vyatta_update_resolv.pl
+++ b/scripts/system/vyatta_update_resolv.pl
@@ -134,10 +134,11 @@ if ($dhclient_script == 1) {
}
}
if ($ns_in_resolvconf == 0) {
- open (APPEND, ">>/etc/resolv.conf") or die "$! error trying to overwrite";
- print APPEND "nameserver\t$ns\t\t#nameserver written by $0\n";
- close (APPEND);
- $restart_ntp = 1;
+ open (my $rf, '>>', '/etc/resolv.conf')
+ or die "$! error trying to overwrite";
+ print $rf "nameserver\t$ns\t\t#nameserver written by $0\n";
+ close $rf;
+ $restart_ntp = 1;
}
}
}
@@ -190,37 +191,40 @@ if ($dhclient_script == 1) {
my @resolv;
if (-e '/etc/resolv.conf') {
- open (RESOLV, '</etc/resolv.conf') or die("$0: Error! Unable to open '/etc/resolv.conf' for input: $!\n");
- @resolv = <RESOLV>;
- close (RESOLV);
+ open (my $f, '<', '/etc/resolv.conf')
+ or die("$0: Error! Unable to open '/etc/resolv.conf' for input: $!\n");
+ @resolv = <$f>;
+ close ($f);
}
my $foundSearch = 0;
my $foundDomain = 0;
-open (RESOLV, '>/etc/resolv.conf') or die("$0: Error! Unable to open '/etc/resolv.conf' for output: $!\n");
+open (my $r, '>', '/etc/resolv.conf')
+ or die("$0: Error! Unable to open '/etc/resolv.conf' for output: $!\n");
+
foreach my $line (@resolv) {
if ($line =~ /^search\s/) {
$foundSearch = 1;
if (length($search) > 0) {
- print RESOLV $search;
+ print $r $search;
}
} elsif ($line =~ /^domain\s/) {
$foundDomain = 1;
if (length($domain) > 0) {
- print RESOLV $domain;
+ print $r $domain;
}
} else {
- print RESOLV $line;
+ print $r $line;
}
}
if ($foundSearch == 0 && length($search) > 0) {
- print RESOLV $search;
+ print $r $search;
}
if ($foundDomain == 0 && length($domain) > 0) {
- print RESOLV $domain;
+ print $r $domain;
}
-close (RESOLV);
+close ($r);