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.

Versions and Naming Conventions

The current version of Perl is Perl 5.6, with a develop version, v5.7, already in production. Some sites are migrating to v5.6, others seem to be dragging their heels, although there are no major compatibility problems. Up until March 2000, the situation concerning the available versions of Perl was quite complex, but we will start with the current version first. From the release of Perl 5.6 there are two very simple strands. Even version numbers, such as 5.6 and 5.8 are considered to be stable releases of the language.
Odd version numbers, such as 5.7 and 5.9, are development releases. Perl 5.6 was a long time coming over two years since the last major release but it also set a landmark for Perl's development. It was the first version that really reunited the core and Win32 versions of Perl, as well as providing some compatibility enhancements. For example, the Windows ports now support fork, something not natively provided by the Windows operating system. Also updated were the Perl compiler and the threading system (which actually supports the Windows fork function), and the addition of a new keyword, our, which handles global variables in the same way as my. Discussions have already started for Perl 6. Unlike Perl 5, which was a complete rewrite of Perl 4 and was developed and coded almost entirely by Larry, Perl 6 will have its feature set determined by the people that use it, through a series of RFCs (Requests for Comments). The language's core code will be developed by a team of programmers with input and assistance from Larry, and with features agreed upon by committees, rather than solely by Larry.

  1. Windows OS

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.


At the most basic level, all windowing platforms (Apple Macintosh, X Windows, and Microsoft Windows) are very simple. They provide a low-level API to create and manage windows, to report interesting events such as mouse and keyboard events, and to draw graphical elements such as lines, circles, and bitmaps. The problem is that drawing even a simple form takes a considerable amount of code and reading thousands of pages of documentation. Often-used patterns of GUI code have evolved into widgets (called "controls" in the Microsoft Windows world); examples include
  1. buttons,
  2. scrollbars, and
  3. listboxes.

Building Perl GUI

Building a GUI is now a simple matter of launching an interactive form designer and dragging and dropping these ready-made components into a layout of your choice. Object-oriented programming has never been easier. It turns out that widgets and scripting languages are a perfect match. Widgets have simple interfaces, and form-based GUIs are not performance-critical. Both of these attributes make GUIs a very fertile ground for scripting. Combine that with the fact that GUIs need the most configurability (because that's the part of the application the user deals with, and for the most part, the GUI is the application), and you can understand the enormous popularity of tools such as Visual Basic, PowerBuilder, and Hypercard. On Unix systems, X Windows has been the windowing platform of choice. Several widget toolkits have been built over X: Athena, InterViews, Motif, and Tk. For professional good looks, ease of use, and documentation, you can't beat Tk. To top it all, it is free! Unlike other widget toolkits, Tk was developed expressly to be driven by a scripting language: Tcl.
Indeed, it can be argued that Tk is the chief reason for Tcl's popularity. There are a lot of people who don't like Tcl as a scripting language but love Tk, and have attempted to adapt it to their favorite scripting language:
  1. Scheme,
  2. Python,
  3. Guile and
  4. Perl.
Malcolm Beattie made the initial attempt to provide a Perl layer that internally used the Tcl interpreter to reach the Tk library.

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.


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.