[Contents] [Prev] [Next] [Index] [Report an Error]

Importing Perl Modules and Declaring Constants

Include the following statements at the start of the application. The first statement imports the functions provided by the JUNOS::Device object, which the application uses to connect to the JUNOScript server on a routing platform. The second statement provides error checking and enforces Perl coding practices such as declaration of variables before use.

     use JUNOS::Device;
     use strict;

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

If the application uses constants, declare their values at this point. For example, the sample diagnose_bgp.pl script includes the following statements to declare constants for formatting output:

     use constant OUTPUT_FORMAT => "%-20s%-8s%-8s%-11s%-14s%s\n";
     use constant OUTPUT_TITLE => 
          "\n=============== BGP PROBLEM SUMMARY ===============\n\n";
     use constant OUTPUT_ENDING => 
          "\n===================================================\n\n";

The load_configuration.pl 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;

[Contents] [Prev] [Next] [Index] [Report an Error]