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
@@ -739,3 +739,12 @@ sub get {
-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;
@@ -757,3 +766,18 @@ sub as_hash {
}
- 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(@_) // {}}
}

Return to:

Send suggestions and report system problems to the System administrator.