summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-04 10:57:58 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-04 10:57:58 -0800
commit9f171d3f9c52c9be5fa281d9b7d8ad7c22f66c27 (patch)
tree23df6fa502890fc0f2af46f819185b99aa7f7797
parentd8922b367e5d45dc8bb2b5dfba59d9473c3403e8 (diff)
downloadvyatta-cfg-9f171d3f9c52c9be5fa281d9b7d8ad7c22f66c27.tar.gz
vyatta-cfg-9f171d3f9c52c9be5fa281d9b7d8ad7c22f66c27.zip
Vyatta::Config - don't use global handle for opendir
Global file handles are trap waiting to happen.
-rwxr-xr-xlib/Vyatta/Config.pm24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm
index 86c8455..4b3690f 100755
--- a/lib/Vyatta/Config.pm
+++ b/lib/Vyatta/Config.pm
@@ -85,9 +85,9 @@ sub listNodes {
}
#print "DEBUG Vyatta::Config->listNodes(): path = $path\n";
- opendir DIR, "$path" or return ();
- @nodes = grep !/^\./, readdir DIR;
- closedir DIR;
+ opendir my $dir, "$path" or return ();
+ @nodes = grep !/^\./, readdir $dir;
+ closedir $dir;
my @nodes_modified = ();
while (@nodes) {
@@ -120,9 +120,9 @@ sub listOrigNodes {
}
#print "DEBUG Vyatta::Config->listNodes(): path = $path\n";
- opendir DIR, "$path" or return ();
- @nodes = grep !/^\./, readdir DIR;
- closedir DIR;
+ opendir my $dir, "$path" or return ();
+ @nodes = grep !/^\./, readdir $dir;
+ closedir $dir;
my @nodes_modified = ();
while (@nodes) {
@@ -155,9 +155,9 @@ sub listOrigNodesNoDef {
}
#print "DEBUG Vyatta::Config->listNodes(): path = $path\n";
- opendir DIR, "$path" or return ();
- @nodes = grep !/^\./, readdir DIR;
- closedir DIR;
+ opendir my $dir, "$path" or return ();
+ @nodes = grep !/^\./, readdir $dir;
+ closedir $dir;
my @nodes_modified = ();
while (@nodes) {
@@ -484,9 +484,9 @@ sub hasTmplChildren {
my $tpath = $self->getTmplPath($cfg_path_ref);
return unless $tpath;
- opendir(TDIR, $tpath) or return;
- my @tchildren = grep !/^node\.def$/, (grep !/^\./, (readdir TDIR));
- closedir TDIR;
+ opendir (my $tdir, $tpath) or return;
+ my @tchildren = grep !/^node\.def$/, (grep !/^\./, (readdir $tdir));
+ closedir $tdir;
return (scalar(@tchildren) > 0);
}