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

I am once again seeking some help (it's been a while which is good...I think?). What I am trying to do it sort a hash in a predetermined order by its value. I am sure there is an easy way to accomplish this but I'm a little stuck on it.

Here's the code thus far :

#!/usr/bin/perl use strict; use warnings; use Net::Telnet::Cisco; my $host = ''; my $ssh = Net::Telnet::Cisco->new(Host => $host); $ssh->login('xxxx','xxxx'); my %int; my @output = $ssh->cmd("show ip interface brief"); foreach my $item(@output){ chomp $item; $item =~ s/^\s+//; my($interface,$ip,$ok,$method,$status,$protocol) = split(/\s+/,$it +em); next if !defined $interface or $interface eq 'Interface'; next if $ip eq 'unassigned'; $int{$interface}{ip} = $ip; $int{$interface}{ok} = $ok; $int{$interface}{method} = $method; $int{$interface}{status} = $status; $int{$interface}{protocol} = $protocol; } foreach my $member (keys %int){ print "$member: "; foreach my $mem_value (keys %{$int{$member}}){ print "$mem_value = $int{$member}{$mem_value} "; } print "\n"; }

I would like to order the output in the order in which I fill the hash as listed above, so (ip, ok, method, status, protocol). This is going to eventually be used as a nagios check and it would be great if the output could be in a consistent order.

Thank you for your wisdom