my %Relevant; my %Possible; foreach my $e (@{$data->{check}}) { #first go though the health checks looking to see if we have relevant checks for this event code if ($e->{Relavant_events} =~ $FindEvent ) { $WantedFile = $e->{filename}; $WantedText = $e->{find}; #scan the files for the text we are after DXWanted(); if ($FileStatus == 1) { $Relevant{$e->{severity}} = $e->{note}; $FileStatus = 0; } } #we also want to run checks for non-relevant items, so we can add them under the "Automation also found..." text on the internal note. else{ $WantedFile = $e->{filename}; $WantedText = $e->{find}; #scan the files for the text we are after DXWanted(); if ($FileStatus == 1) { $Possible{$e->{severity}} = $e->{note}; $FileStatus = 0; } } } #all the checks have been run - now sort the 2 hashes, and print out their contents to the note. my $RelavantCount = scalar keys %Relavant; if ($RelavantCount >= 1) { foreach my $name (sort { $b <=> $a } keys %Relavant) { $RESULTS = $RESULTS . "Severity: " . $name . "\n" . $Relavant{$name} . "\n\n" } }