http://qs321.pair.com?node_id=1088620

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

Dear monks,

Thank you for your time and effort in advance. Well my question can be extremely simple to someone who has figure this out, but is seems a bit complicated to someone who is not familiar.

Two days ago I discovered this powerful module Net::SNMP::Interfaces.

The uniqueness and beauty of this tool is that it can detect non sequential interfaces. Which at my case is exactly what I was looking for.

While I was trying to experiment with the tool I read:

From: Net::SNMP::InterfacesThere is a also a fourth optional argument 'RaiseError' which determines the behaviour of the module in the event there is an error while creating the SNMP. Normally new() will return undef if there was an error but if RaiseError is set to a true value it will die() printing the error string to STDERR. If this is not set and an error occurs undef will be return and the variable $Net::SNMP::Interfaces::error will contain the test of the error. Because the interfaces are discovered in the constructor, if the module is to be used in a long running program to monitor a host where interfaces might be added or removed it is recommended that the object returned by new() is periodically destroyed and a new one constructed.

Well while I was trying to play around to see the error in case that I am using the RaiseError option active, I would expect to see the error printed.

Sample of working code displayed under:

#!/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, ) or die $Net::SNMP::Interfaces::error; my @ifnames = $interfaces->all_interfaces(); print Dumper (\@ifnames);

For testing purposes I have changed on the code the port to 1161, on the effort to produce an error and display it.

I assume that I am using wrong syntax on the RaiseError => 1 option so I also tried RaiseError => 'TRUE' but unfortunately not printing the error.

The output that I am getting is the following:

Net::SNMP::Interfaces: at test.pl line 10.

So my question is am I doing something wrong? Or I am asking too much details when it come to printing the error?

Thanks again for everyone's time and effort.

Seeking for Perl wisdom...on the process...not there...yet!