Subject: | Small change to make Net::SNMP::PDU::var_bind_list more compatible with Net::SNMP::XS |
From the source for Net::SNMP::XS:
http://cpansearch.perl.org/src/MLEHMANN/Net-SNMP-XS-1.2/XS.pm
package Net::SNMP::PDU;
# var_bind_list hardcodes oid_lex_sort. *sigh*
# we copy it 1:1, except for using oid_lex_sort.
sub var_bind_list
{
my ($this, $vbl, $types) = @_;
...etc...
@{$this->{_var_bind_names}} = Net::SNMP::oid_lex_sort keys %$vbl;
...etc...
}
So, fixing this would require one change:
Old: @{$this->{_var_bind_names}} =
map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map
{
my $oid = $_;
$oid =~ s/^\.//;
$oid =~ s/ /\.0/g;
[$_, pack 'N*', split m/\./, $oid]
} keys %{$vbl};
New: @{$this->{_var_bind_names}} = Net::SNMP::oid_lex_sort keys %$vbl;
The line in question looks to be completely compatible with the non-XS
version. The replacement oid_lex_sort is functionality identical to the
hardcoded routine. Unless I'm mistaken, this is probably just an
oversight when you were replacing other hardcodes with oid_lex_sort.
This change wouldn't actually do anything functionality, but it would
mean that the XS author wouldn't need to put in the entire subroutine
and keep things sync'd up when it changes.