| # Perl
Perl is a very powerful scripting language and is fully supported by The Uniform Server Zero. You can install one of two distributions, either Portable Strawberry Perl via a Uniform Server Zero Plugin or Active Perl. The ActivePerl Community License precludes distribution with The Uniform Server Zero; you will need to download this yourself and use The Uniform Server Zero's built-in installation batch file script. Remainder of this page; covers UniControllers Perl control menu. ## Overview Install Perl as explained on this page Installing Perl The Uniform Server automatically detects the presence of Perl and enables UniController. If Perl is not installed, the Perl menu is greyed out. Place your Perl scripts in folder UniServerZ\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:/UniServerZ/core/perl/bin/perl.exe
Or (Unix format)
    #!/usr/bin/perl
Note: The #! means "use the following command/interpreter to run this script". Generally the command/interpreter is the absolute path to an executable Next section covers the Shebang in more detail. ## Shebang The Shebang format you use is dependent on a number of factors such as on how the Apache server is run (either as a standard program or as a service) and the operating system. ### Apache – Running as standard program When Apache is started from UniController it is run as a standard program and is fully portable. For portability absolute paths cannot be used, instead the Perl executable is located by using the local environment path. The Shebang used for Windows is shown below:
    #!perl
Moving UniServer Zero to another location automatically updates the path environment variable. Tip: When writing Perl scripts for Windows always use #!perl for the shebang. Important: When you place a third party Perl script in cgi-bin, you must always run Force Windows Shebang using UniController this converts the Unix Shebang to the Windows format. Alternatively, you can manually edit each file and replace the Unix Shebang "#!/usr/bin/perl" with the Windows Shebang "#!perl". ### Apache – Running as service When Apache is started from UniService it is run as a service and is no-longer portable. Running as a service requires the Shebang to be an absolute path for example:
    #!C:/UniServerZ/core/perl/bin/perl.exe
You need to edit each file and replace the Shebang with "#!C:/UniServerZ/core/perl/bin/perl.exe", if you installed Uniform Server in a different location adjust the path as appropriate. Although inconvenient it is a relatively easy task to search all files in cgi-bin and replace the Shebang. Note 1: The above runs on any Windows OS from XP to Win 10. Note 2: With the exception of Windows XP that must use the above there is a more elegant solution see Unix Shebang on Windows for details. ## Shebang Help Perl > Shebang Help The Perl "Shebang Help" menu displays the following: Shebang Help: Perl scripts developed on Unix will not run on a Window machine the Shebang requires conversion to a Windows format. The Shabang allows Apache to find the Perl interpreter Windows Shebang - First line of a Perl script: #!perl Note 1: After installing third-party scripts to the cgi-bin folder. Force a Windows shebang update by running "Force Windows Shebang". from the Perl drop-down menu. Note 2: Before uploading scripts from the cgi-bin folder to a Unix server. Force a Unix shebang update by running "Force Unix Shebang" from the Perl drop-down menu. ## Force Windows Shebang After installing third-party scripts to the cgi-bin folder. Force a Windows shebang update by running Force Windows Shebang from the Perl drop-down menu. Perl > Force Windows Shebang This updates all files with the following file extensions in folder cgi-bin and any sub-folders *.pl *.pm *.cgi Replaces the current shebang with #!perl ## Force Unix Shebang Perl scripts developed on Windows will not run on a Unix machine. They require conversion to Unix format. Force a format update by running Force Unix Shebang from the Perl drop-down menu. Perl > Force Unix Shebang This updates all files with the following file extensions in folder cgi-bin and any sub-folders *.pl *.pm *.cgi Replaces the current shebang with #!/usr/bin/perl ## View test.pl View test.pl runs test script: UniServerZ\cgi-bin\test.pl Perl > View test.pl test.pl
    #!perl

    print <<END_of_HTML;
    Content-type: text/html

    <HTML>
     <HEAD>
      <TITLE>Perl Test Page</TITLE>
     </HEAD>

     <BODY>
     <H1>Perl test page</H1>
      <P>Basic Perl test pages.</P>
      <ul>
         <li><a href="http://localhost/cgi-bin/test_1.pl/" target="_blank">test_1.pl - Display Perl environment</a></i>
         <li><a href="http://localhost/cgi-bin/test_2.pl/" target="_blank">test_2.pl - Basic "Hello world" uses here-doc <<END statement:</a></i>
         <li><a href="http://localhost/cgi-bin/test_3.pl/" target="_blank">test_3.pl - Basic "Hello world" uses use CGI qw(:standard)</a></i>
         <li><a href="http://localhost/cgi-bin/test_4.pl/" target="_blank">test_4.pl - Basic user input form 1</a></i>
         <li><a href="http://localhost/cgi-bin/test_5.pl/" target="_blank">test_5.pl - Basic user input form 2</a></i>
      </ul>

    <p>The above test pages are located in folder <b>UniServerZ\\cgi-bin</b> after testing these pages can be deleted:<br />
    Main Test page test.pl and pages test_1.pl to test_5.pl</p>

     </BODY>

    </HTML>
    END_of_HTML
## Where to go next Installing Perl - Covers installing ActivePerl and Strawberry Perl