Import Perl Modules and Declare Constants in NETCONF Perl Client Applications
When creating a NETCONF Perl client application, include
the following statement at the start of the application. This statement
imports the functions provided by the Net::Netconf::Manager
object, which the application uses to connect to the NETCONF server
on a device.
use Net::Netconf::Manager;
Include statements to import other Perl modules as appropriate for your application. For example, several of the sample scripts included in the NETCONF Perl distribution import the following standard Perl modules, which include functions that handle input from the command line:
Carp—Includes functions for user error warnings.
Getopt::Std—Includes functions for reading in keyed options from the command line.
Term::ReadKey—Includes functions for controlling terminal modes, for example suppressing onscreen echo of a typed string such as a password.
If the application uses constants, declare their values at this point. For example, the sample script diagnose_bgp.pl includes the following statement to declare a constant for the access method:
use constant VALID_ACCESS_METHOD => 'ssh';
The edit_configuration.pl sample script includes the following statements to declare constants for reporting return codes and the status of the configuration database:
use constant REPORT_SUCCESS => 1; use constant REPORT_FAILURE => 0; use constant STATE_CONNECTED => 1; use constant STATE_LOCKED => 2; use constant STATE_CONFIG_LOADED => 3;