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

I'm using the Net::SNMP module to requests for gets and walks to a server, I thought it would be a good idea to use the lex_oid_sort function to get my array of OIDs in to a logical order before sending the requests. The strange thing is, the function always returns an array where the first element is "Net::SNMP" with the rest of it being the sorted OIDs. Here's a test I threw together:
use strict; use Net::SNMP; my @unsort = qw/ 1.3.6.1.2.1.1.5 1.3.6.1.2.1.1.4 1.3.6.1.2.1.1.1 1.3.6 +.1.2.1.1.2/; my @sort = Net::SNMP->oid_lex_sort(@unsort); local $, = "\n"; print @unsort; print "\n-------\n"; print @sort;
Output:
1.3.6.1.2.1.1.5 1.3.6.1.2.1.1.4 1.3.6.1.2.1.1.1 1.3.6.1.2.1.1.2 ------- Net::SNMP 1.3.6.1.2.1.1.1 1.3.6.1.2.1.1.2 1.3.6.1.2.1.1.4 1.3.6.1.2.1.1.5
Any clue why it's doing this? I'm fairly new to this whole perl module thing, but the documentation doesn't say anything about this kind of behavior.

Replies are listed 'Best First'.
Re: Confusion with Net::SNMP
by Transient (Hermit) on Jul 07, 2005 at 15:46 UTC
    the -> notation passes in the LHS as the first arg. Try Net::SNMP::oid_lex_sort(@unsort).
      Yep, thanks. Works as I'd expect it to now.