Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


Import Perl Modules and Declare Constants in Junos XML Protocol Perl Client Applications

When creating a Junos XML protocol Perl client application, include the following statements at the start of the application. The use JUNOS::Device; statement imports the functions provided by the JUNOS::Device object, which the application uses to connect to the Junos XML protocol server on a device running Junos OS. The use strict statement provides error checking and enforces Perl coding practices such as declaration of variables before use.

Include statements to import other Perl modules as appropriate for your application. For example, several of the sample scripts included in the Junos XML protocol Perl distribution import the following standard Perl modules, which include functions that handle input from the command line:

  • File::Basename—Includes functions for processing filenames.

  • 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 includes the following statements to declare constants for formatting output:

The sample script includes the following statements to declare constants for reporting return codes and the status of the configuration database: