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!

In reply to Net::SNMP::Interfaces how to print the error() by thanos1983

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.