1

My First Perl Idiom

Concept I Perl is an interpreted language

Source code for Perl is created in a text editor. Text editors are simple ASCII code serially laid out in a file. Each byte of the ASCII code represents a character which can be displayed on a screen or other output device. The standard text editor in Unix is the visual editor (vi). Unlike a word processor, there is no extraneous information in a text file produced by a text editor for formatting or the inclusion of graphics.

Concept II The first line in a Perl program generally indicates to the shell where Perl is, and that it is to interpret the rest of the text file as executable code.

Concept III She Bang Notation - The marks at the beginning (#!) of all perl executable files in Unix which clue the OS about how to execute the file.

Concept IV When a file is marked as executable within the operating system, upon execution the file is opened and read by the computer operating system and it's contents are examined to determine how to execute it. If the file is binary, the code is executed on the spot. If not, the computer tries to determine how it is expected to execute the file. When the first line in the file is as follows:

#!/usr/bin/perl

the #! notation (She Bang Notation) tells the environment to look for the listed program. The results of your which perl command should be entered on this line.

Concept V The code that follows this first line is now fed to Perl and parsed by the Perl interpreter. After parsing the code, Perl builds a binary image in the RAM of your computer, running the program you created. This binary is never stored on your hard drive.

Concept VI Other programming languages require the code to be precompiled as a binary file before being executed. A parser parses the code, and optimizer optimizes it for your purposes, and then a linker brings together binary code together to create an executable. Examples of this kind of languages is C, C++ and SmallTalk.

Concept VII The Perl interpreter is written in C. Perl compiles it's source code using the C compiler to create it's runtime binary image which sits in RAM. In this respect, a Perl program is truly a C executable.

Concept VIII Advantages and Disadvantages of interpretive programming Languages:

Advantages

· Interpretive languages like Perl are generally easier to write and debug

since the program is actual text.

· Nothing needs to learned about complex compiler options

and usage.

Disadvantages

· Programs generally run slower

· Source code is always visible

· Can not use advanced compiler options

· More difficult to write large programs

· Some debugging aspects unavailable

Perl is very much the best of both worlds. It compiles to a C binary in RAM and yet is easy to write.It adopts many of C's best features such as it's ability to use external libraries. Perl is easy to extend with runtime allocated routines.

NEXT:SSECOND IDIOM