Commit 850d698d authored by Leo Gordon's avatar Leo Gordon
Browse files

now with a setter function

parent 97659a83
......@@ -87,5 +87,26 @@ sub get {
return $option_value;
}
1;
sub set {
my $self = shift @_;
my $value = pop @_;
my $key = pop @_;
my $hash_ptr = $self->config_hash;
foreach my $context_syll (@_) {
unless(exists $hash_ptr->{$context_syll}) {
$hash_ptr->{$context_syll} = {};
}
$hash_ptr = $hash_ptr->{$context_syll};
}
if(ref($hash_ptr->{$key}) ne ref($value)) {
die "Mismatch of types in Config::set(".join(',',@_,$key,$value).") : trying to set a ".(ref($value)||'scalar')." instead of ".ref($hash_ptr->{$key});
} else {
$hash_ptr->{$key} = $value;
}
}
1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment