Skip to content
Snippets Groups Projects
Commit cf2c2506 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Added function to generate changes between hashes

parent a6c32ac4
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@ our (@ISA,@EXPORT,@EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT = qw(
prettyUndef
getHashChanges
toHex
isVariable
isUsername
......@@ -53,6 +54,27 @@ sub prettyUndef
}
# Function to return the changes between two hashes using a list of keys
sub getHashChanges
{
my ($orig,$new,$keys) = @_;
my $changed = { };
foreach my $key (@{$keys}) {
# We can only do this if we have a new value
if (defined($new->{$key})) {
if (!defined($orig->{$key}) || $orig->{$key} ne $new->{$key}) {
$changed->{$key} = $new->{$key};
}
}
}
return $changed;
}
# Return hex representation of a decimal
sub toHex
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment