use strict; use Net::SNMP; use Socket; my $MIB1 = "1.3.6.1.2.1.2.2.1.1"; my $HOST = "128.128.2.10"; my $COMM = "public"; my $SNMP = 'snmpv2c'; my ($session, $error) = Net::SNMP->session( -hostname => $HOST, -version => $SNMP, -community => $COMM ); my $result = $session->get_table( -baseoid => $MIB1 ); foreach(keys %$result) { # Zero-Pad content with length of 1 $result->{$_} = ( (length($result->{$_}) == 1) ? "0$result->{$_}" : $result->{$_} ); } # Sort our hash via the _Value_ of the hash keys... numerically ascending foreach my $key ( sort { $result->{$a} <=> $result->{$b} } ( keys( %$result ) ) ) { print( $result->{$key} . "\n"); }