http://www.perlmonks.org?node_id=893112

jgn has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I am new'ish to Perl and have taken on a project to create some scripts to monitor some Windows Servers.

The piece that is giving me a lot of trouble is sorting my hash of hashes I am generating as I go through a list of machines.

This is my snippet that tacks a hash onto the hash for each machine that meets my criteria, 97% full volume.
if (( $pctused ) > 97 ) { $srvlist{ $srvname } = { pctused => "$pctused", volname => "$volname", volfree => "$volfree" }; }
This all works fine. Each machine that meets this criteria is tacked onto the hash. However I am at a complete loss for how to sort by the value of one of these keys when I generate my report. I have tinkered with the various sort methods I have found in my google search and no joy.

While I'm sure there is a better way to do it than I have here... My question is how can I sort by key value in a hash of hashes and "rebuild" it as a sorted list for say ... sticking it into an HTML table?


Thanks in advance