################
#COMPARE_N_SUBSTITUTE
#Compare a hash to a fall-through hash. If any values are present in the fall-through and not in the current values then insert them in the DYC hash.
#compare_n_substitute(hash1, hash2) #insert key-value-pairs from hash2 into hash1 only if those pairs are not defined in hash1.
#compare_n_substitute(%hash, %default)
sub compare_n_substitute(%%) {
my ($hashref, $fallthrough_hashref) = @_;
for my $key (keys %$fallthrough_hashref) {
unless (defined($$hashref{$key})) {
$$hashref{$key} = $$fallthrough_hashref{$key};
}
}
}
provide default values for a hash
Leave a Reply
You must be logged in to post a comment.