in reply to My Perl-foo... SORT is not strong

You're sorting by $Relevant{$key}, which you've populated with $e->{note}. Try a plain sort { $b <=> $a } keys %Relevant maybe?

Replies are listed 'Best First'.
Re^2: My Perl-foo... SORT is not strong
by Greg@Work (Initiate) on Mar 19, 2015 at 15:21 UTC

    Thank you for your quick reply. I'm horribly new to Perl and it's nice to have someone looking over my shoulder. I made the change you suggested and sadly am getting an error - probably since I didn't show you all the code....

    #all the checks have been run - now sort the 2 hashes, and print out t +heir contents to the note. my $ReleventCount = scalar keys %Relevent; if ($ReleventCount >= 1) { foreach my $name (sort { $b <=> $a } keys %Relevant) { $RESULTS = $RESULTS . "Severity: " . $name . "\n" . $Relevent{ +$name} . "\n\n" } }

    Error: Global symbol "%Relevant" requires explicit package name at PSFT_Automation.pl line 641. Execution of PSFT_Automation.pl aborted due to compilation errors. Again, Thanks for helping me out

      Note the spelling: "Relevant" is not "Relevent".

        Thank you for your patience. I fixed my spelling errors... *looks sheepish*. Still got the Global symbol "%Relavant" requires explicit package name at PSFT_Automation.pl line 636. Error. (line 636 is the line my $RelavantCount = scalar keys %Relavant; near the end). 2 things look strange to me.. one is I'm declaring the hash at the first line.. Adding to the hash uses $ not %... is that correct? and secondly is this the proper way to get a count of the elements in the hash? my $RelavantCount = scalar keys %Relavant; ?? Again, can't thank you guys enough.

        my %Relevant; my %Possible; foreach my $e (@{$data->{check}}) { #first go though the health checks looking to see if we have r +elevant 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 no +te. 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 o +ut 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" } }

        But its spelling is relevant.