SPUG: Barewords and Net::SNMP
Jim Flanagan
jimfl at colltech.com
Wed Dec 5 13:56:29 CST 2001
--On Wednesday, December 5, 2001 11:25 AM -0800 "Martin, Asa"
<asa.martin at attws.com> wrote:
> 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.
OCTET_STRING is a constant, which means it is a subroutine which returns
a constant, which the perl compiler will inline the constant that the
subroutine returns (rather than have a subroutine call at runtime). So
the assignment that you want to make is
my $type = OCTET_STRING ;
Then $type will have the appropriate value for be used in the
set_request() call.
--
Jim Flanagan
jimfl at colltech.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
More information about the spug-list
mailing list