Web Perl   «Prev  Next»

Lesson 2 Setting up environment
Objective Set up working environment with a Web server

Setting up your Perl Environment

If you do not already have a server running or access to a server's CGI directory, this lesson will provide you with links to downloads for Web servers and recent versions of Perl. Please keep in mind that this course is about Perl and CGI, not installing a Web server and/or new operating system. Your objective is to obtain an understanding of how Perl is used with web programming.
  • Setting up Perl for Unix and Web Servers:
    The latest Unix version of Perl is here. This version will work with most Unix-like and Unix-ish systems (including Linux, SunOS, SCO, Plan 9, etc., plus VMS and OS/2). You must compile this Perl, and you will probably want to use the GNU gcc compiler (which is probably already installed on your system if you are using Unix), to ensure that you get all of Perl's features. The Apache server is by far the most popular server on the Net right now. It is also the platform that this author uses for his personal and public servers. Apache Web Server is probably the fastest server available. In addition, it is free, full-featured, and is at the forefront of new developments including support for the new HTTP protocols. Apache comes with source code and will compile on most Unix, and unix-like platforms, and OS/2 as well. The Apache Web server is an extremely fast and reliable Web server. It is indisputably the most popular server on the Internet. Apache supports all the latest Web features, including the latest version of HTTP, and it was the first server to support multiple domains on one machine. Apache is standard issue with both of the Linux distributions mentioned above.
  • Setting up Perl 6 (Raku) on a Windows 11 machine involves the following steps:
    1. Download the Rakudo Compiler

      Rakudo is the reference compiler for the Raku programming language. To set up Perl 6, you need Rakudo.

      • Go to the Rakudo downloads page.
      • Select the pre-built binary for Windows. Typically, this is a .zip file containing the Rakudo compiler and related tools.
    2. Extract the Rakudo Distribution
      • Extract the downloaded .zip file into a directory of your choice, such as C:\rakudo.
    3. Install and Configure a Back-End Virtual Machine (Optional)

      Rakudo supports two backends:

      1. MoarVM (default and most commonly used)
      2. JVM (optional, requires Java)

      The binary distribution usually includes MoarVM, so no additional setup is needed. If you're interested in the JVM backend:

      • Ensure you have Java installed.
      • Modify the Rakudo configuration files to use the JVM backend.
    4. Set Environment Variables

      To run rakudo or perl6 commands from any directory:

      1. Open Settings → System → About → Advanced System Settings.
      2. Click on Environment Variables.
      3. Add the directory containing rakudo.exe to the Path system variable:
        • Click Edit under System Variables → Path.
        • Add the path (e.g., C:\rakudo\bin).
    5. Verify Installation
      • Open Command Prompt or PowerShell.
      • Run:
      perl6 --version
              

      You should see output confirming that Rakudo (Perl 6) is installed and providing version details.

    6. Install Modules (Optional)
      • Use zef, the module management tool included with Rakudo, to install additional Raku modules:
      zef install <module-name>
              
    7. Create and Run a Test Script:
      1. Create a new file named `test.p6` with the following content:
        raku
        say "Hello, Raku!";
        
      2. Run the script in the terminal:
        perl6 test.p6
        

    You should see the output `Hello, Raku!`.
    Additional Notes
    • Raku (Perl 6) is evolving, and newer distributions may use `raku` instead of `perl6` as the command-line executable. Always refer to the latest documentation.
    • If you encounter issues, ensure you have administrator privileges during installation and verify the `Path` configuration.
  • Setting up Perl for Mac:
    There exists a Mac version of Perl, called MacPerl. Mac Perl gains ground.
    You can find the MacPerl FAQ here in that same directory. A number of different servers for the Mac. It makes interesting reading (and their conclusions are similar to mine. Mac OS, which stands for Macintosh Operating System, is the trademarked name for a series of graphical user interface-based operating systems developed by Apple Computer for their Macintosh line of computer systems. The Mac OS is often credited with popularizing the graphical user interface. It was first introduced in 1984 with the original Macintosh 128K.


Perl Binary | Perl Language

Hence, Perl is the binary and Perl is the language. The former parses and runs the latter: perl parses and runs Perl and if someone writes PERL, you know immediately that they are not familiar with the Perl language. This is why sometimes you see experienced programmers use PERL to refer to poorly written Perl programs. Due to the wording of the original documentation that shipped with Perl, many programmers assume that PERL is an acronym for Practical Extraction and Report Language. However perlfaq, the documentation that shipped with Perl sets the record straight:
never write "PERL", because perl is not an acronym, apocryphal folklore and post-facto expansions notwithstanding.

Remember, there is no such thing as PERL. It is
  1. Perl, the language, or
  2. perl, the executable.


Perl Dynamic Programming Languages

Perl, Python, Ruby, and PHP are all examples of dynamic programming languages. In contrast to languages such as Java, C++, and other static programming languages, the dynamic languages often delay certain things until run time that static languages might decide at compile time, such as determining which class a method will dispatch to. Dynamic languages tend to be rapid to develop in, but have certain kinds of errors that are less common in static languages. Discussions about dynamic and static typing are about type theory, and the terms are poorly defined. However, there is one solid rule you should remember: Computer scientists have reasonable disagreements about type theory, whereas computer programmers have unreasonable ones. If you get into "static versus dynamic language" debates, and you do not understand type theory, you are going to sound like a non-computer scientist to those who do. In the next lesson, you will get a general overview of the role of CGI in the grand scheme of things, and the capabilities of a CGI program.

SEMrush Software