SPUG: Barewords and Net::SNMP
Martin, Asa
asa.martin at attws.com
Wed Dec 5 13:25:07 CST 2001
I have a specific question about the Net::SNMP module, but it also could be
a general question regarding barewords and constants. Hopefully I'll make
this clear.
The Net::SNMP module defines a method called set_request, that takes as an
argument a reference to an array, like this:
$session->set_request(-varbindlist => \@oid_value)
The middle value of this array is a type value, several of which are
exported by Net::SNMP. For example, the documentation shows this:
my $sysContact = '1.3.6.1.2.1.1.4.0';
my $result = $session->set_request(
-varbindlist => [$sysContact, OCTET_STRING, 'Help Desk x911']
);
This works all well and good. However, when I try and do something like
this:
my $sysContact = '1.3.6.1.2.1.1.4.0';
my $type = 'OCTET_STRING';
my $value = 'Help Desk x911';
my $result = $session->set_request(
-varbindlist => [$sysContact, $type, "$value"]
);
It errors out saying:
Unknown ASN.1 type [OCTET_STRING].
even though according to the docs, OCTET_STRING "exported" by default.
Is there a way to force the $type variable to be considered a "bareword" by
Perl and have it interpolate correctly? I don't know if that is phrased
correctly, but hopefully you understand the question. I'm also sending this
to the author of Net::SNMP and he might be able to shed some light on the
matter.
Thanks so much.
Asa Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/spug-list/attachments/20011205/b8601200/attachment.htm
More information about the spug-list
mailing list