aboutsummaryrefslogtreecommitdiff
path: root/SBO-Lib/lib
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-08-29 00:05:25 +0200
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-08-29 00:05:25 +0200
commit223ad71044440c87257d8dfa5d43d1ade78bc764 (patch)
tree13b11080ce079be1e55ac733827506e9a8aa2114 /SBO-Lib/lib
parentd44ddf7b6cf98d3bfc1e65ec9600061c8407cc91 (diff)
downloadsbotools-223ad71044440c87257d8dfa5d43d1ade78bc764.tar.xz
SBO::Lib::Util: read_config can use slurp()
Diffstat (limited to 'SBO-Lib/lib')
-rw-r--r--SBO-Lib/lib/SBO/Lib/Util.pm23
1 files changed, 8 insertions, 15 deletions
diff --git a/SBO-Lib/lib/SBO/Lib/Util.pm b/SBO-Lib/lib/SBO/Lib/Util.pm
index 52b1a9d..efc40b6 100644
--- a/SBO-Lib/lib/SBO/Lib/Util.pm
+++ b/SBO-Lib/lib/SBO/Lib/Util.pm
@@ -354,23 +354,16 @@ There is no useful return value.
# subroutine to suck in config in order to facilitate unit testing
sub read_config {
- my %conf_values;
- if (-f $conf_file) {
- _race::cond('$conf_file might not exist after -f');
- my ($fh, $exit) = open_read($conf_file);
- if ($exit) {
- warn $fh;
- $config{SBO_HOME} = '/usr/sbo';
- return;
+ my $text = slurp($conf_file);
+ if (defined $text) {
+ my %conf_values = $text =~ /^(\w+)=(.*)$/mg;
+ for my $key (keys %config) {
+ $config{$key} = $conf_values{$key} if exists $conf_values{$key};
}
- my $text = do {local $/; <$fh>};
- %conf_values = $text =~ /^(\w+)=(.*)$/mg;
- close $fh;
- }
- for my $key (keys %config) {
- $config{$key} = $conf_values{$key} if exists $conf_values{$key};
+ $config{JOBS} = 'FALSE' unless $config{JOBS} =~ /^\d+$/;
+ } else {
+ warn "Unable to open $conf_file.\n";
}
- $config{JOBS} = 'FALSE' unless $config{JOBS} =~ /^\d+$/;
$config{SBO_HOME} = '/usr/sbo' if $config{SBO_HOME} eq 'FALSE';
}