Declare Perl API modules and variables

This section of the SNMP GET access example Perl script declares the Perl API modules to be used as well as a number of variables. Use this part of the example script as a guide to setting up client/server Perl scripts that will retrieve SNMP information.

The SNMP GET access example Perl script declares the Perl API modules to be used and a number of variables as follows:


#!$NCHOME/bin/ncp_perl
 use strict;  1 
 use RIV;
 use RIV::Param;
 use RIV::App;
 use RIV::SnmpAccess; # qw (RivSnmpResultOk);  2 

 $RIV::SnmpAccess::MaxAsyncConcurrent = 40;  3 

 my $Ttype = "TEST";  4 
 my $Verbose;
 my @_Usage = ("node" [async]);

The following list explains specific numbered items in the previously listed section of the SNMP GET access Perl script example:

  1. Declares the strict pragma with the use directive. The strict pragma enforces good programming practices, including enforcing the declarations of any new variables with my.
  2. Specify the use directive to declare the Perl API modules to be used. In this case, use the RIV, RIV::Param, RIV::App, and RIV::SnmpAccess modules.
  3. Sets the MaxAsyncConcurrent RIV::SnmpAccess module variable to the value 40. This module variable sets the maximum number of concurrent asynchronous SNMP get requests.
  4. Declare the following my variables:
    • $Ttype — Stores a string that identifies whether the SNMP GET access is synchronous or asynchronous. Later sections of the SNMP GET access example script use this variable in calls to the print operator. The variable gets set initially to the string TEST.
    • $Verbose — Specifies how the script progress details are to be displayed. The -v option displays verbose progress details. This variable is defined with the RIV::Param module, specifically with the Usage method.
    • @_Usage — Specifies the usage string suffixes node and async.