mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-05-04 11:01:27 +02:00
general-function.pl: Add a function to easily set defaults
This function can be used to set values in a hash if they have not been set, yet. Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -202,6 +202,17 @@ sub get_aliases
|
||||
}
|
||||
}
|
||||
|
||||
sub set_defaults($$) {
|
||||
my $hash = shift;
|
||||
my $defaults = shift;
|
||||
|
||||
foreach my $key (keys %$defaults) {
|
||||
unless (defined($hash->{$key})) {
|
||||
$hash->{$key} = $defaults->{$key};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub readhash
|
||||
{
|
||||
my $filename = $_[0];
|
||||
|
||||
Reference in New Issue
Block a user