bartrad has asked for the wisdom of the Perl Monks concerning the following question:
Hi all, after a bit of advice if I could please? I have the following hash that I'm trying to sort by the value against CPU.
$VAR1 = { 'hostname' => { '1' => { 'pass' => + 1, 'cpu' => +'0.07%', 'box_name +' => 'hostname', 'capacity +' => '0.41%' } }, 'hostname' => { '1' => { 'pass' => 1 +, 'cpu' => '0 +.04%', 'box_name' +=> 'hostname', 'capacity' +=> '0.25%' } },
Here's my code, but I'm getting
Use of uninitialized value in numeric comparison (<=>) at ./cpu_check.pl line 157.so I must not be doing it properly?
foreach my $router ( sort {$results->{1}{cpu}{$a} <=> $results->{1}{cpu}{$b} } keys %$results )Thank you
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Sorting hash
by ablanke (Monsignor) on Apr 05, 2018 at 18:37 UTC | |
by bartrad (Beadle) on Apr 05, 2018 at 18:39 UTC | |
by ablanke (Monsignor) on Apr 05, 2018 at 19:01 UTC | |
by pryrt (Abbot) on Apr 05, 2018 at 19:30 UTC | |
by ablanke (Monsignor) on Apr 05, 2018 at 22:56 UTC | |
| |
Re: Sorting hash
by pryrt (Abbot) on Apr 05, 2018 at 18:50 UTC |
Back to
Seekers of Perl Wisdom