To: Mr. Muskrat,

Thanks for the clarification part, I was not sure if I did understand correctly.

Well in conclusion, by using the die command:

my $interfaces = Net::SNMP::Interfaces->new( Hostname => '192.168.18 +4.11', Community => 'public', Port => '1161', #RaiseError => 1, )or die $Net::SNMP::Interfaces::error; my @ifnames = $interfaces->all_interfaces(); print Dumper (\@ifnames);

The output is:

No response from remote host "127.0.0.1" at test.pl line 10

By changing the code to:

my $interfaces = Net::SNMP::Interfaces->new( Hostname => '127.0.0.1' +, Community => 'public', Port => '1161', RaiseError => 1, ); my @ifnames = $interfaces->all_interfaces();

The output is:

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

The whole point of my question was that I would like to see a printout like:

22:19:01.537280 IP 0.0.0.0 > 0.0.0.0: ICMP 0.0.0.0 udp port 1161 unrea +chable, length 36

Which the actual output of TCPDUMP, in order to inform the user that the port or community or what ever the error is wrong.

Both solutions indicate that the error comes from line 10 which is Net::SNMP::Interfaces request so there is an indication, I was just looking for something extra since the documentation said that there might give more information if the user include the RaiseError => 1 command.

Update:

By removing the RaiseError => 1 the (HASH %arg) like:

my $interfaces = Net::SNMP::Interfaces->new( Hostname => '192.168.18 +4.11', Community => 'public', Port => '1161', ); my @ifnames = $interfaces->all_interfaces(); print Dumper (\@ifnames);

The error becomes:

Can't call method "all_interfaces" on an undefined value at test.pl li +ne 12.

Which points out to the array, which makes the user wonder what is the error, well in this case I would suggest to use one of the upper solutions so at least the user get's an idea of the error and not be looking at the wrong direction.

Thank you all for your time and effort, replying to my question.

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

In reply to Re^2: Net::SNMP::Interfaces how to print the error() by thanos1983
in thread 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.