G'day Virus2500,

Welcome to the monastery.

"... which i want to get "translated" by Net::SNMP."

You may find some of these (from Net::SNMP's documentation) useful:

"However afaik Net::SNMP translates the bareword INTEGER into an integer value... right?"

You can find the answer to this by tracking back through the code. Doing so will likely increase your understanding of the module and how it works.

From source code for Net::SNMP v6.0.1:

use Net::SNMP::PDU qw( :ALL !DEBUG_INFO );

From source code for Net::SNMP::PDU v6.0.1:

use base qw( Net::SNMP::Message ); sub import { return Net::SNMP::Message->export_to_level(1, @_); }

[See Exporter - Exporting Without Using Exporter's import Method for export_to_level() doco.]

From source code for Net::SNMP::Message v6.0.1:

our %EXPORT_TAGS = ( ... types => [ qw( INTEGER INTEGER32 OCTET_STRING ... ... ); Exporter::export_ok_tags( qw( ... types ... ) ); $EXPORT_TAGS{ALL} = [ @EXPORT_OK ]; ## ASN.1 Basic Encoding Rules type definitions sub INTEGER { 0x02 } # INTEGER sub INTEGER32 { 0x02 } # Integer32 - SNMPv2c sub OCTET_STRING { 0x04 } # OCTET STRING ...

I'll leave you to explore further ...

[While reviewing this source code, also look at sub prepare { ... }), which contains the source of your error message (i.e. $_[0]->_error('The ASN.1 type "%s" is unknown', $_[1])).]

"ERROR: The ASN.1 type "OCTET_STRING" is unknown"

Net::SNMP exports the symbol OCTET_STRING by default. The same is true for INTEGER. From source code for Net::SNMP v6.0.1:

use base qw( Exporter ); our @EXPORT = qw( INTEGER INTEGER32 OCTET_STRING ... );

Below this, are other ways to import them:

our %EXPORT_TAGS = ( asn1 => [ qw( INTEGER INTEGER32 OCTET_STRING ... ... Exporter::export_ok_tags( qw( asn1 debug generictrap snmp translate ) +); $EXPORT_TAGS{ALL} = [ @EXPORT_OK ];

[See also: Net::SNMP - EXPORTS]

Check how you are loading Net::SNMP; compare that with Net::SNMP - EXAMPLES.

[See also: use; Exporter]

-- Ken


In reply to Re: Use hash variable as constant by kcott
in thread Use hash variable as constant by Virus2500

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.