To clarify what hexcoder said...
Based on the documentation, $Net::SNMP::Interfaces::error is only set if you haven't used RaiseError => 1. You should be able to do one of the following:
#!/usr/bin/perl use strict; use warnings; use Net::SNMP::Interfaces; use Data::Dumper qw(Dumper); my $interfaces = Net::SNMP::Interfaces->new( Hostname => '127.0.0.1', Community => 'public', Port => '1161', RaiseError => 1, # Errors are fatal ); my @ifnames = $interfaces->all_interfaces(); print Dumper (\@ifnames);
#!/usr/bin/perl use strict; use warnings; use Net::SNMP::Interfaces; use Data::Dumper qw(Dumper); my $interfaces = Net::SNMP::Interfaces->new( Hostname => '127.0.0.1', Community => 'public', Port => '1161', ) or die $Net::SNMP::Interfaces::error; my @ifnames = $interfaces->all_interfaces(); print Dumper (\@ifnames);
In reply to Re: Net::SNMP::Interfaces how to print the error()
by Mr. Muskrat
in thread Net::SNMP::Interfaces how to print the error()
by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |