|
|
|
||||
|
|
Perl
(Practical Extraction and Report Language) is an interpreted
programming language that pattern matches, manipulates
information, and is useful for systems administration
automation. Over time, it has become the language of choice
for most of the CGI's currently in use on the Web.
By default, your VPS1 should already have the Perl5 standard libraries installed. If not, or if you wish to reinstall them, follow the directions below. Installing Perl5
Perl can be called in two ways:
You can call Perl by running the program on the first line of the file with the #! notation. For example, if you are creating a script with Perl, open a file and enter #!/usr/local/bin/perl. This action informs the computer that the script is a Perl script. Duplicating the Virtual EnvironmentRemember, the same problem of confusing the VPS1 with the physical server can appear when pathing to Perl. When you enter which perl from the command line, the Perl returned is the first Perl seen in your .cshrc$path. If this is Perl4, you may be pathing to the wrong Perl (i.e. /usr/local/bin/perl4). If you desire to execute the script duplicating the virtual environment, use the virtual command:
The first line in the env.cgi file is #!/usr/local/bin/perl, so the Perl5 binary is used for the script. Perl can also take command line options, which can be useful in debugging scripts. They can also be included on the first line of your script. For example, the following causes Perl to check the syntax of the script:
The following forces Perl to look in the /usr/local/lib/perl5 directory for include files:
The following forces Perl to print warnings about various things:
Note: When a script does not work properly, the -w and -c options can help debug by generating warnings and check for syntax errors. In addition to these options, check your web server error log files for errors. Checking Your Server's Error Log Files
The following are some common problems and possible solutions that can occur with Perl scripts on a VPS1. Failure to Upload Your Perl Script in ASCII ModePerl scripts, unlike compiled executables, are plain text files. Plain text files should be transferred from your local computer to your VPS1 using ASCII mode (not BINARY mode). Failure to transfer your Perl scripts to your VPS1 in ASCII mode may result in 500 Server Errors. Problems with Perl5 ScriptsScript requires Perl5, but Perl5 is not on the VPS1. Or: The path to Perl that the script uses is #!/usr/local/bin/perl4 rather than #!/usr/local/bin/perl. Solution Install Perl5. Installing Perl5Connect to your VPS1 via Telnet or SSH, and from the command prompt execute the following commands:
After installing Perl5, point to your new Perl installation by editing your CGI script. Editing Your CGI Script
to:
This action runs your Perl program with the Perl5 interpreter rather than perl4, located in ~/usr/bin/perl. The Perl install now installs a hard linked copy of Perl5. This saves space on the VPS1 (about 10.8 megabytes). Vinstall can also install the linked copy of Perl5: Improper Path Specification of Perl Interpreter The first line of a Perl script indicates the path name of the Perl interpreter. In the VPS1 environment, the correct specification of your Perl5 interpreter is /usr/local/bin/perl. If you downloaded a Perl script from a third party source, the Perl interpreter is most often defined based on the author's host environment, which may be different from the VPS1 environment. In addition, if you have uploaded a Perl script to your VPS1, ensure that the script includes the proper path definition to the Perl5 interpreter. The location of the Perl4 interpreter is specified as /usr/local/bin/perl4, whereas the Perl5 interpreter location should be specified as /usr/local/bin/perl. A Sample Problem with UtilitiesUtilities such as sendmail do not seem to work. SolutionBecause the problem is probably a pathing issue (such as /usr/sbin/sendmail being used rather than /bin/sendmail), you must change the paths from physical server paths to VPS1 paths. Note: To ensure that your script is calling paths to the VPS1 environment, see the previous section entitled "The VPS1 vs. the Physical Server" for more information. A Sample Problem with a Perl Script ModuleA module is not found in the Perl script, which is probably because of a pathing issue (usr or require not pathing to the correct Perl module) or module is not included in the current Perl installation. SolutionsAny of the following solutions can solve the problem of when a module is not found in the Perl script:
|
||
|
|
||||
|