Skip to content

Make ordering of mappings and application stable#29

Open
sputtene wants to merge 1 commit intozabbix-tools:masterfrom
sputtene:fix/stable-ordering-of-mappings-and-applications
Open

Make ordering of mappings and application stable#29
sputtene wants to merge 1 commit intozabbix-tools:masterfrom
sputtene:fix/stable-ordering-of-mappings-and-applications

Conversation

@sputtene
Copy link

Perl 5.8.1 added hash randomisation (see
https://metacpan.org/release/JHI/perl-5.8.1/view/pod/perldelta.pod#Hash-Randomisation).

The effect is that multiple invocations of keys %hash return the hash keys in
different ordering, even between separate runs of the script with the same
inputs.

As a result, running the script multiple times, yielded non-identical XML
output, since the order of the mappings and application lists is different
every time.

By first sorting the hash keys for the mapping and application hashes before
iterating over them, multiple runs of the script with the same inputs result in
identical output.

Perl 5.8.1 added hash randomisation (see
https://metacpan.org/release/JHI/perl-5.8.1/view/pod/perldelta.pod#Hash-Randomisation).

The effect is that multiple invocations of `keys %hash` return the hash keys in
different ordering, even between separate runs of the script with the same
inputs.

As a result, running the script multiple times, yielded non-identical XML
output, since the order of the mappings and application lists is different
every time.

By first sorting the hash keys for the mapping and application hashes before
iterating over them, multiple runs of the script with the same inputs result in
identical output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant