Coral: perl intro

From The Uniform Server Wiki
Jump to navigation Jump to search

Perl - Introduction Guide

Perl is a very powerful scripting language and is fully supported by The Uniform Server. Since the ActivePerl Community License precludes distribution with The Uniform Server, you will have to download it yourself. However, Perl is easy to install when using The Uniform Server's builtin script. For details, see Perl - Installing ActivePerl. This page covers UniController's menu option that displays the Perl control panel.

UniServer 8-Coral
  Home
  Quick Start
  General
  Apache
  MySQL
  PHP
  MSMTP
  CRON
  DtDNS
  Db Backup
» Perl
  Main Index

Overview

The Uniform Server automatically detects the presence of Perl and enables the functionality to support it in UniController. If Perl is not installed, the Perl control panel buttons are greyed out.

Auto tracking

Place your Perl scripts in folder UniServer\cgi-bin and any sub-folders as appropriate. Each script requires a Shebang. This must be an absolute path to the Perl executable. For example:

#!C:/UniServer/usr/bin/perl.exe

Moving UniServer to another location automatically updates this Shebang. UniController, on detecting a server move, writes a new Shebang to all files with a .pl or .cgi extension. An automatic update is initiated only when the servers are moved.

Important: When you place a third party Perl script in cgi-bin, you must either move the servers or force a Shebang update using UniController. Alternatively, you can manually edit each file.


UniController support

Force Shebang update

Perl scripts contain a Shebang (the first line) which informs a server where to find the Perl program. The Uniform Server is dynamic and tracks any path changes, automatically updating the Shebang.


However if the server remains static and you add new scripts, the Shebang is never updated. You must therefore run "Force Shebang update" from the Perl control panel. It updates the Shebang to the current Perl location in all files.


Tip: When writing Perl scripts you can use the following for the Shebang:

#!

From the Perl control panel, run "Perl Shebang Update" and all pages will be updated with the correct Shebang.

Convert to Unix format

Perl scripts developed on Windows will not run on a Unix machine. They require conversion to Unix format. You can run the conversion script from the Perl control panel.

This script copies all files in cgi-bin to a new folder \cgi-bin-unix\
Scripts in this new folder are converted from Windows to Unix format.

  • Converts end of line: Dec(#13#10=>#10) Hex 0D0A to 0A
  • Replaces Windows Shebang with Unix Shebang

Top

Perl control panel

This sub-menu option opens the Perl control panel.

Server Configuration > Perl > Perl control panel

  1. Force Shebang Update
    Rewrites the Shebang in all .pl and .cgi files infolder UniServer\cgi-bin and its sub-folders.
  2. Convert Win2Nix
    Copies the folders and files in cgi-bin to folder \cgi-bin-unix\ and converts from Windows to Unix format.
  3. Run Test Script
    Runs the script UniServer\cgi-bin\test.pl


Top

Where to next

Perl - Installing ActivePerl

Top