aboutsummaryrefslogtreecommitdiff
path: root/lib/App/Glacier/Config.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/Glacier/Config.pm')
-rw-r--r--lib/App/Glacier/Config.pm28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/App/Glacier/Config.pm b/lib/App/Glacier/Config.pm
index 33d54d2..63dd61c 100644
--- a/lib/App/Glacier/Config.pm
+++ b/lib/App/Glacier/Config.pm
@@ -737,7 +737,16 @@ sub get {
return $ref;
}
-sub as_hash {
+=head2 $cfg->as_hashref(@path)
+
+If I<@path> represents a section, convert that section to a perl hash,
+and return a reference to that hash.
+
+If I<@path> does not exist or refers to a value, return C<undef>.
+
+=cut
+
+sub as_hashref {
my $self = shift;
my $ref = $self->getref(@_);
my $hroot = {};
@@ -755,7 +764,22 @@ sub as_hash {
$elt->[2]{$elt->[0]} = $elt->[1]->{-value};
}
}
- return $hroot->{''};
+ my $r = $hroot->{''};
+ return ref($r) eq 'HASH' ? $r : undef;
+}
+
+=head2 $cfg->as_hashref(@path)
+
+If I<@path> represents a section, return that section converted to a
+perl hash.
+
+If I<@path> does not exist or refers to a value, the returned hash is
+empty.
+
+=cut
+
+sub as_hash {
+ return %{shift->as_hashref(@_) // {}}
}
=head2 $cfg->isset(@path)

Return to:

Send suggestions and report system problems to the System administrator.