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

Hello Monks,

Anyone know why I can't declare the TYPE dynamically

I.E. my $type = 'INTEGER'
This is how I'm declaring my varbind
if (($Gen_ID == 2) || ($Gen_ID == 3)) { $trapvars[0] = "1.3.6.1.2.1.2.2.1.1"; $trapvars[1] = INTEGER; $trapvars[2] = $value[1]; $trapvars[3] = "1.3.6.1.2.1.2.2.1.1"; $trapvars[4] = INTEGER; $trapvars[5] = $value[2]; $trapvars[6] = "1.3.6.1.2.1.2.2.1.7"; $trapvars[7] = INTEGER; $trapvars[8] = $value[3]; $trapvars[9] = "1.3.6.1.2.1.2.2.1.8"; $trapvars[10] = INTEGER; $trapvars[11] = $value[4]; }
I had to use 'INTEGER' specifically

Any ideas?

Replies are listed 'Best First'.
Re: Why can't I declare Net::SNMP varbinds dynamically
by Kanji (Parson) on Feb 04, 2003 at 00:54 UTC

    From your my() declaration, I would say you're being tripped up by INTEGER being a constant that returns a value other than 'INTEGER'.

    To use it properly, all you need do is omit your quotes...

    my $type = INTEGER;

        --k.


Re: Why can't I declare Net::SNMP varbinds dynamically
by Anonymous Monk on Feb 03, 2003 at 20:55 UTC
    if it's any help, I'm getting the following error:
    Error sending trap: Unknown ASN.1 type [INTEGER]
    when I try to set $type = "INTEGER";